#t400. 打包(pack)
打包(pack)
Gifts
Background
Special for beginners, ^_^
Problem Description
You have now received many gifts and want to put them into a bag. You have only one bag that can hold items of volume at most , so you cannot put everything in. You also cannot carry everything because of the weight; you estimate the maximum weight you can carry to be .
Now you know the perfection value, weight, and volume of each gift. Naturally, you want to maximize the total perfection value of the gifts put into the bag, so you have to plan it out.
Input Format
First line: and , the maximum volume and maximum weight.
Second line: , meaning you received gifts.
Lines to : each line has numbers , the perfection value, weight, and volume of each gift.
Output Format
Output one number: the maximum perfection value that can be obtained.
Sample Input 1
6 5
4
10 2 2
20 3 2
40 4 3
30 3 3
Sample Output 1
50
Constraints
1s, 1024KiB for each test case.
For of the data, ;
For of the data, ;
For of the data, ;
The data from to are discrete random data with .