AT_abc475_b.Change
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In the Kingdom of AtCoder, three kinds of coins — 1-yen coins, 10-yen coins, and 100-yen coins — and 1000-yen bills are in circulation.
Takahashi made N purchases, starting from a state where he had 10100 1000-yen bills and 0 coins.
In the i-th purchase, he bought an item worth Ai yen.
For the payment, he paid using only the minimum number of 1000-yen bills such that the total amount paid was at least Ai yen, and received the change so that the total number of coins received as change was minimized.
Find the number of each type of coin that Takahashi has at the point when all N purchases are finished.
在 AtCoder 王国,流通着三种硬币:1 日元硬币、10 日元硬币和 100 日元硬币,以及 1000 日元纸币。
高桥进行了 N 次购物,初始状态为拥有 10100 张 1000 日元纸币,且没有硬币。
在第 i 次购物中,他购买了一件价值 Ai 日元的商品。
付款时,他仅使用最少张数的 1000 日元纸币,使得所付总额至少为 Ai 日元;找零时,则使得作为找零收到的硬币总枚数最少。
求在完成全部 N 次购物后,高桥所拥有的每种硬币的数量。
输入格式
The input is given from Standard Input in the following format:
N
A1 … AN
输入从标准输入中按以下格式给出:
N
A1 … AN
输出格式
Output the number of 1-yen coins, 10-yen coins, and 100-yen coins that Takahashi has at the point when the N purchases are finished, in this order, separated by spaces.
输出高桥在完成 N 次购买后所拥有的 1 日元硬币、10 日元硬币和 100 日元硬币的数量,按此顺序以空格分隔。
输入输出样例
输入#1
3 1296 110 1
输出#1
13 18 24
输入#2
12 3141 592 65358 9 79 323 84 6264 3 38327 950 28
输出#2
52 59 82
说明/提示
Sample 1 Explanation:
In the first purchase, for the payment of 1296 yen, Takahashi pays with two 1000-yen bills, and receives seven 100-yen coins and four 1-yen coins as change.
In the second purchase, for the payment of 110 yen, he pays with one 1000-yen bill, and receives eight 100-yen coins and nine 10-yen coins as change.
In the third purchase, for the payment of 1 yen, he pays with one 1000-yen bill, and receives nine 100-yen coins, nine 10-yen coins, and nine 1-yen coins as change.
At the point when the three purchases are finished, he has 13 1-yen coins, 18 10-yen coins, and 24 100-yen coins.
Constraints
- 1≤N≤1000
- 1≤Ai≤105
- All input values are integers.
样例 1 解释:
第一次购物中,对于 1296 日元的付款,高桥使用了两张 1000 日元纸币支付,并收到七枚 100 日元硬币和四枚 1 日元硬币作为找零。
第二次购物中,对于 110 日元的付款,他使用了一张 1000 日元纸币支付,并收到八枚 100 日元硬币和九枚 10 日元硬币作为找零。
第三次购物中,对于 1 日元的付款,他使用了一张 1000 日元纸币支付,并收到九枚 100 日元硬币、九枚 10 日元硬币和九枚 1 日元硬币作为找零。
当完成这三次购物后,他共持有 13 枚 1 日元硬币、18 枚 10 日元硬币和 24 枚 100 日元硬币。
限制条件
- 1≤N≤1000
- 1≤Ai≤105
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?