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?
- A. 74
- B. 68
- C. 54
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many subsets of [2, 3, 5, 7, 4, 1, 6, 8] (chosen by position, the empty set excluded) have a sum of exactly 10?
- The numbers [31, 26, 33, 21, 40] are split into two groups (every number goes to exactly one group). What is the smallest possible…
- Each number in [1, 2, 3, 4, 5, 6, 7] gets a sign '+' or '-', and all are then added. How many sign choices give a total of exactly 4?
- How many NON-EMPTY subsets of [4, 7, 2, 9, 5, 3, 8, 6] have a sum divisible by 3? Subsets are chosen by position.
- Items as (weight, value) are [(3, 5), (4, 6), (5, 9), (7, 13), (2, 8)]. Each item can be used at most once. What is the maximum value of a…
- From the numbers [17, 22, 9, 35, 41, 13, 28], choose a subset (each number used at most once) whose sum is as large as possible without…