Unlimited Supplies
Same knapsack, but every item is available in unlimited quantity. Maximize the value within capacity W.
Input: the first line has N and W; each of the next N lines has wi and vi.
Output: the maximum total value with repetition allowed.
Constraints:
- 1 ≤ N ≤ 100
- 1 ≤ W ≤ 1000
- 1 ≤ wi ≤ 1000
- 0 ≤ vi ≤ 104
Sample Tests
Input 1
2 8 3 30 5 60
Output 1
90
Input 2
1 3 2 5
Output 2
5
Discussion (opens after you solve — no spoilers before)
No comments yet.