Multiple Knapsack Problem


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Problem type
Allowed languages
C++, Python

Bounded Knapsack Problem

There are N types of items and a knapsack with capacity V.

Each item of type i has a maximum availability of si units. Each unit of type i has a volume of vi and a value of wi.

Determine which items to put into the knapsack such that the total volume does not exceed the capacity and the total value is maximized. Output the maximum value.

Input Format

The first line contains two integers, N and V (0 < N ≤ 1000, 0 < V ≤ 20000), separated by a space, representing the number of item types and the knapsack capacity respectively.

The next N lines each contain three integers vi, wi, si, separated by spaces, representing the volume, value, and maximum quantity for the i-th type of item.

Output Format

Output a single integer, representing the maximum value.

Constraints

0 < N ≤ 1000

0 < V ≤ 20000

0 < vi, wi, si ≤ 20000

Note

This problem tests the monotonic queue optimization method for the Bounded Knapsack problem.

Sample Input

4 5
1 2 3
2 4 1
3 4 3
4 5 2

Sample Output

10

Comments

There are no comments at the moment.