#d1302. 工作安排
工作安排
Job Scheduling
Problem Background
John has far too much work to do.
To keep the farm running efficiently, he must earn money from his work, and each job takes one unit of time.
His workday starts at time and has units of time in total.
At any moment he may choose to do any one of the jobs numbered to .
Each job has a deadline: for the -th job there is a deadline , and if he completes it he earns a profit .
Given the profits and deadlines, what is the maximum profit John can obtain?
Input Format
The first line contains an integer .
Lines to each contain two integers and .
Output Format
One number: the maximum profit.
Sample Input
3
2 10
1 5
1 7
Sample Output
17
Constraints
.
.