Data Structures & AlgorithmsVery hardTCS NQT · GATE CS

A shop has these items as (weight, value, number available): [(2, 10, 2), (3, 14, 3), (5, 30, 1)]. You may take at most the listed number of each type, and the total weight must not exceed 13. What is the maximum total value?

  1. A. 74
  2. B. 68
  3. C. 54
  4. D. 65

Correct answer: B. 68

Expand each type into k copies, or process each copy as a 0/1 item. Iterating a type's capacity upward (the unbounded rule) allows more copies than the limit, which inflates the value.

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

Exams that ask this topic