Skip to content
C

Job Sequencing with Deadlines

Mediumjavapythonccppjavascript

Each of N jobs has an integer deadline and a profit, and takes exactly one unit of time. Only one job runs at a time, starting at time 1. A job earns its profit only if it finishes by its deadline. Maximise total profit.

Input Format

The first line contains an integer N. Each of the next N lines contains two integers deadline and profit.

Output Format

Print the maximum total profit.

Input (stdin)

Output

Run your code to see output here...