#T440. OJ平台利用
OJ平台利用
Description
We currently have many OJ contests to be held on CodesOnline. Each contest has a unique start and end time. If two OJ contests overlap partially or entirely in time, they cannot be held simultaneously on the OJ platform. Now, we want to maximize the utilization of the OJ platform, where each hour of usage generates a profit of 100 yuan. We need to select a set of non-overlapping OJ contests to hold such that their total duration is as long as possible. We assume that as soon as one contest ends (ignoring seconds), another contest can start immediately.
Write a program: read the start and end times of all contests, and calculate the maximum possible total profit from OJ system usage.
Input Format
The first line contains a positive integer n, representing the number of all contests.
The following n lines each contain two integers p and k separated by a space. Each such pair of integers represents a contest that starts at time p and ends at time k.
Output Format
Output a single integer, representing the maximum total profit.
【Sample Explanation】
You can choose the 3rd, 5th, 6th, 11th, and 12th speeches. This results in the longest total speech duration of 16 hours, with a profit of 100 yuan per hour, yielding a total profit of 1600 yuan.
【Data Range】
1 ≤ n ≤ 10^4; 0 ≤ p < k ≤ 3×10^4
Adapted from 2005 Provincial Selection ProblemSource