270. Job Sequencing with Deadlines
MediumGreedySorting
Each job takes one unit of time, has a deadline and a profit. Schedule jobs (at most one per time slot, finishing by its deadline) to maximise profit. Print the number of jobs done and the total profit.
Input format
Line 1: n Next n lines: deadline profit
Output format
count profit
Example 1
Input
4 4 20 1 10 1 40 1 30
Output
2 60
Example 2
Input
5 2 100 1 19 2 27 1 25 1 15
Output
2 127
Constraints
1 ≤ n ≤ 10⁴ 1 ≤ deadline ≤ n
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…