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

From tasks (value, cost) = (5, 4), (6, 2), (3, 1), (7, 5) you may choose any subset whose total cost is at most 7. What is the maximum number of tasks you can take (ignoring value)?

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

Correct answer: A. 3

Taking cheapest tasks first maximises the count under a single budget by an exchange argument. Choosing by value (the trap) gives a different count.

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

Exams that ask this topic