当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5410:CRB and His Birthday

题目描述
Today is CRB's birthday. His mom decided to buy many presents for her lovely son.
She went to the nearest shop with $M$ Won(currency unit).
At the shop, there are $N$ kinds of presents.
It costs $W_{i}$ Won to buy one present of $i$-th kind. (So it costs $k$ × $W_{i}$ Won to buy $k$ of them.)
But as the counter of the shop is her friend, the counter will give $A_{i}\ ×\ x\ +\ B_{i}$ candies if she buys $x$($x$>0) presents of $i$-th kind.
She wants to receive maximum candies. Your task is to help her.
1 ≤ $T$ ≤ 20
1 ≤ $M$ ≤ 2000
1 ≤ $N$ ≤ 1000
0 ≤ $A_{i},\ B_{i}$ ≤ 2000
1 ≤ $W_{i}$ ≤ 2000
输入解释
There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case:
The first line contains two integers $M$ and $N$.
Then $N$ lines follow, $i$-th line contains three space separated integers $W_{i}$, $A_{i}$ and $B_{i}$.
输出解释
For each test case, output the maximum candies she can gain.
输入样例
1
100 2
10 2 1
20 1 1
输出样例
21
提示
CRB's mom buys 10 presents of first kind, and receives 2 × 10 + 1 = 21 candies.
来自杭电HDUOJ的附加信息
Author KUT(DPRK)
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5410

最后修改于 2020-10-25T23:22:26+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)