#28530. Choosing flowers
Choosing flowers
题目描述
有 种物品,每种物品有无限个,你可以购买 个物品。
对于第 种物品:
第一次买时的贡献是 ,接下来每购买一个的贡献都是 。即当你买了 个第 种物品时,贡献是
现在要你求出最大贡献。
输入格式
第一行一个 ,表示有 组数据。
对于每组数据:
第一行 和
接下来 行,每行两个整数和
每组数据后有一个空行。保证所有测试用例的 值总和不超过 。
输出格式
对于每组数据,输出一行一个整数表示最大的贡献。
2
4 3
5 0
1 4
2 2
5 3
5 2
4 2
3 1
14
16
说明/提示
In the first example case Vladimir can pick 1 flower of the first type and 3 flowers of the second type, in this case the total happiness equals .
In the second example Vladimir can pick 2 flowers of the first type, 2 flowers of the second type, and 1 flower of the third type, in this case the total happiness equals .
相关
在以下作业中: