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

Five jobs given as (processing time, deadline) are (4,4), (2,2), (3,3), (1,1), (6,7). You run them in some order, and a job is late if it finishes after its deadline. What is the minimum number of late jobs?

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

Correct answer: A. 3

Moore-Hodgson: sort by deadline, keep a max-heap of accepted durations, and drop the largest when the schedule overruns. The dropped jobs are the late ones, which are the minimum possible.

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

Exams that ask this topic