Time limit
2s
Memory limit
128 MB
An academic has received lecture requests from n universities, where 0 ≤ n ≤ 10,000. Each university offers a fee p, where 1 ≤ p ≤ 10,000, if the lecture is given within d days, where 1 ≤ d ≤ 10,000. The values p and d may differ for each university.
The academic can give at most one lecture per day. Determine the maximum total fee the academic can earn.
The first line contains the integer n. Each of the next n lines contains two integers p and d, the offered fee and the deadline in days.
Print the maximum total fee that can be earned.