#P1507. NASA的食物计划

NASA的食物计划

Description

The space shuttle has limited volume, and carrying overly heavy items wastes a lot of fuel money. Each food item has its own volume, mass, and contained calories. Given the maximum allowable volume and mass, output the maximum total calories achievable. Each food item can be used at most once.

Input Format

The first line contains 22 integers, representing the maximum volume HH and the maximum mass TT.

The second line contains 11 integer representing the total number of food items nn.

The next nn lines each contain 33 numbers: volume hih_i, mass tit_i, and contained calories kik_i.

Output Format

One integer, representing the maximum total calories achievable (within int range).

320 350
4
160 40 120
80 110 240
220 70 310
40 400 220

550

Hint

For 100%100\% of the testdata, H,T,hi,ti400H, T, h_i, t_i \le 400, n50n \le 50, ki500k_i \le 500.

Translated by ChatGPT 5