Lecture Tour
InterviewTime limit2sMemory limit128 MB
Given jobs each with a fee and a deadline, schedule at most one job per day to maximize total fee collected before deadlines.
- Level
Medium6 of 10
- Topics
- Greedy, Union-find, Sorting
- Solved
- No attempts yet
Problem
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.
Input
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.
Output
Print the maximum total fee that can be earned.