Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

Tasks are (duration, deadline): (4, 2), (2, 1), (3, 2), (1, 1), (5, 3), and a single machine runs them one at a time from time 0. What is the maximum number of tasks that can finish by their deadlines?

  1. A. 1
  2. B. 2
  3. C. 0
  4. D. 5

Correct answer: A. 1

Process tasks in deadline order and, whenever the running total overruns, drop the longest task so far (a heap of durations). This exchange keeps as many tasks as possible.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic