Skip to content
CampusEduX

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.

Related Problems

  • Activity Selection
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Fractional Knapsack
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Minimum Number of Coins
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...