#T443. OJ作业
OJ作业
Description
When registering a CodesOnline account, the system schedules all OJ problems. Each OJ problem earns OJ points only if it is submitted within the specified time limit. The deadline and OJ points for each problem may vary. For example, if an OJ problem offers 10 points and requires submission within 6 days, you must submit it before the end of the 6th day to earn those 10 points.
Each problem takes exactly one day to complete. For instance, suppose there are 7 problems with the following points and deadlines:
| Problem ID | Deadline | OJ Points |
|---|---|---|
| 1 | 1 | 6 |
| 2 | 1 | 7 |
| 3 | 3 | 2 |
| 4 | 3 | 1 |
| 5 | 2 | 4 |
| 6 | 2 | 5 |
| 7 | 6 | 1 |
The maximum achievable points are 15, with one possible completion order being 2, 6, 3, 1, 7, 5, 4. Note that other methods may also exist.
Your task is to find an order to complete the problems that maximizes the total OJ points earned.
Input Format
The first line contains an integer X, representing the number of problems.
The next X lines each contain two integers: the first integer indicates the problem's deadline, and the second integer represents its OJ points.
Output Format
Output an integer representing the maximum achievable points. It is guaranteed that the answer does not exceed the range ofC/C++'sint.
【Data Range】
For 20% of the data, X ≤ 10^3;
For 40% of the data, X≤10^4;
For 60% of the data, X≤10^5;
For 100% of the data, X≤10^6, and the completion deadlines for all problems are less than 7×10^5.
Adapted from "Olympiad Tutorial" problem setSource