#abc373f. F - Knapsack with Diminishing Values
F - Knapsack with Diminishing Values
Score : points
问题陈述
有 种物品。第 种物品的重量为 ,价值为 。每种物品有 个可用。
高桥打算选择一些物品并将它们放入容量为 的背包中。他希望在避免选择太多同种物品的同时,最大化所选物品的价值。因此,他定义选择 个第 种物品的幸福度为 。他希望在选择物品时最大化所有类型的总幸福度,同时保持总重量不超过 。计算他能够实现的最大总幸福度。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There are types of items. The -th type of item has a weight of and a value of . Each type has items available.
Takahashi is going to choose some items and put them into a bag with capacity . He wants to maximize the value of the selected items while avoiding choosing too many items of the same type. Hence, he defines the happiness of choosing items of type as . He wants to choose items to maximize the total happiness over all types while keeping the total weight at most . Calculate the maximum total happiness he can achieve.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 10
3 4
3 2
Sample Output 1
5
By choosing items of type and item of type , the total happiness can be , which is optimal.
Here, the happiness for type is , and the happiness for type is .
The total weight is , which is within the capacity .
Sample Input 2
3 6
1 4
2 3
2 7
Sample Output 2
14
Sample Input 3
1 10
1 7
Sample Output 3
12