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

建议使用的浏览器:

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

5527:Too Rich

题目描述
You are a rich person, and you think your wallet is too heavy and full now. So you want to give me some money by buying a lovely pusheen sticker which costs $p$ dollars from me. To make your wallet lighter, you decide to pay exactly $p$ dollars by as many coins and/or banknotes as possible.

For example, if $p = 17$ and you have two $\$10$ coins, four $\$5$ coins, and eight $\$1$ coins, you will pay it by two $\$5$ coins and seven $\$1$ coins. But this task is incredibly hard since you are too rich and the sticker is too expensive and pusheen is too lovely, please write a program to calculate the best solution.
输入解释
The first line contains an integer $T$ indicating the total number of test cases. Each test case is a line with 11 integers $p, c_1, c_5, c_{10}, c_{20}, c_{50}, c_{100}, c_{200}, c_{500}, c_{1000}, c_{2000}$, specifying the price of the pusheen sticker, and the number of coins and banknotes in each denomination. The number $c_i$ means how many coins/banknotes in denominations of $i$ dollars in your wallet.

$1 \le T \le 20000$
$0 \le p \le 10^9$
$0 \le c_i \le 100000$
输出解释
For each test case, please output the maximum number of coins and/or banknotes he can pay for exactly $p$ dollars in a line. If you cannot pay for exactly $p$ dollars, please simply output '-1'.
输入样例
3
17 8 4 2 0 0 0 0 0 0 0
100 99 0 0 0 0 0 0 0 0 0
2015 9 8 7 6 5 4 3 2 1 0
输出样例
9
-1
36
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5527

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

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 262144/262144K(Java/Others)