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

建议使用的浏览器:

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

6685:Rikka with Coin

题目描述
Rikka hates coins, and she used to never carry any coins with her. These days, Rikka is doing her summer internship abroad. Without mobile payment, Rikka has to face strange prices of commodities, and as a result of always using paper currency, she has to face mountainous coins on here table.

In the local currency system, there are $4$ kinds of coins: $10$ cents, $20$ cents, $50$ cents and $1$ dollar. Up to now, Rikka has gained at least $10^{100}$ coins for each kind.

Now, Rikka is going to have dinner in the canteen, and she decides to pay the bill only with coins. There are $n$ different combos in the canteen and the price of the $i$th is $w_i$ cents. Rikka would like to choose one combo as dinner but she has not decided to choose which one yet. Therefore, she wants to take some coins so that whichever she chooses, she can always pay the bill without receiving any change.

Since Rikka hates coins, she wants to carry as few coins as possible with her. As it is generally known that Rikka is not good at math, she wants you to help her make the decision.
输入解释
The first line of the input contains a single integer $T(1 \leq T \leq 500)$, the number of test cases.

For each test case, the first line contains a single integer $n(1 \leq n \leq 100)$, the number of combos sold in the canteen.

The second line contains $n$ positive integers $w_1, \dots, w_n(1 \leq w_i \leq 10^9)$, which represents the prices.
输出解释
For each test case, output a single line with a single integer which represents the minimum number of coins. If there is no valid solution, output $-1$.

Hint
In the first test case, one optimal solution is to bring one coin of $10$ cents and two coins of $20$ cents.

In the second test case, one optimal solution is to bring $5$ coins of one dollar.
输入样例
3
5
10 20 30 40 50
5
100 200 300 400 500
1
1
输出样例
3
5
-1
来自杭电HDUOJ的附加信息
Recommend chendu

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

源链接: HDU-6685

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

共提交 0

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