Problems > Limited Stock Knapsack

Limited Stock Knapsack

Difficulty: 1900 6000 ms 128 MB

dp

Each item i has weight wi, value vi, and is available at most ci times. Maximize value within capacity W.

Input: the first line has N and W; each of the next N lines has wi vi ci.

Output: the maximum achievable value.

Constraints:

  • 1 ≤ N ≤ 100
  • 1 ≤ W ≤ 104
  • 1 ≤ ci ≤ 1000

Sample Tests

Input 1
2 5
2 3 2
3 4 1
Output 1
7
Input 2
1 4
2 5 3
Output 2
10

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.