#P1757. 通天之分组背包
通天之分组背包
Description
After the knapsack came out, Xiao A became very interested. One day, Xiao A went on a trip and found that his backpack was different from the knapsack. His items can be roughly divided into groups, and items within the same group are mutually exclusive (you may choose at most one item from each group). Now he wants to know the maximum total value he can obtain.
Input Format
Two integers , indicating there are items in total, and the backpack can bear a maximum weight of .
Then lines follow. Each line contains 3 integers , representing the item's weight, value, and group index.
Output Format
One integer: the maximum total value.
45 3
10 10 1
10 5 1
50 400 2
10
Hint
, , , are within the int range.
Translated by ChatGPT 5
京公网安备 11011102002149号