AdvancedRating 1600
Deadlines and Profits
Each job takes one unit of time and has a deadline and a profit. Schedule jobs to maximise total profit. Print the number of jobs done and the profit.
Input
n, then n lines 'deadline profit'.
Output
Two numbers.
Sample 1
Input
4 4 20 1 10 1 40 1 30
Output
2 60
Sample 2
Input
5 2 100 1 19 2 27 1 25 3 15
Output
3 142
Output appears here