#P1782. 旅行商的背包
旅行商的背包
Description
Little S firmly believes that any problem can be solved in polynomial time, so he decides to be a traveling salesman for once. Before setting off, he bought some items. There are types of items; for the -th type, the volume is , the value is , and there are items available. His knapsack has a capacity of . How should he pack to obtain the maximum total value? As a top guru, he solved this easily.
However, just before departure, he received another batch of special goods. There are such goods, and for the -th one, the relationship between its value and the allocated volume is: . This is good news, but Little S does not know how to handle it, so he turns to a super guru (that is, you) to help him solve this problem.
Input Format
The first line contains three integers , as described above.
The next lines each contain three integers , as described above.
The next lines each contain three integers , as described above.
Output Format
Output a single line: the maximum value.
2 1 10
1 2 3
3 4 1
-1 8 -16
10
Hint
Sample explanation:
Take all of the first two types of items. Allocate volume to the last special good. The total value is $2 \times 3 + 4 \times 1 + (-1) \times 16 + 8 \times 4 + (-16) = 10$.
Constraints and Notes
For of the testdata, , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号