CF208D.Prizes, Prizes, more Prizes
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.
Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.
The sweepstake has the following prizes (the prizes are sorted by increasing of their cost):
- a mug (costs a points),
- a towel (costs b points),
- a bag (costs c points),
- a bicycle (costs d points),
- a car (costs e points).
Now Vasya wants to recollect what prizes he has received. You know sequence _p_1, _p_2, ..., p__n, where p__i is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.
瓦西娅和许多人一样,喜欢参加各种抽奖和彩票活动。目前,他正在收集一种名为“朱庇特”的知名巧克力棒的包装纸。根据抽奖规则,每张包装纸上都印有一个整数——即顾客购买该巧克力棒时所获得的积分。当参与者累计达到一定积分后,便可前往奖品发放中心,用积分兑换奖品。每当某人领取一个奖品时,该奖品的价格将直接从其当前积分中扣除。
瓦西娅不仅购买了巧克力棒,还详细记录了每张包装纸所提供的积分数量。此外,他还记得自己始终遵循贪心策略:一旦积分足以兑换至少一个奖品,他便会立即前往奖品发放中心,并用积分兑换奖品;而且,若当时可选多个奖品,他总是优先选择价格最贵的那个。如果兑换完一个奖品后,他剩余的积分仍足以兑换至少一个奖品,则他会继续兑换,直至剩余积分不足以兑换任何奖品为止。
本次抽奖活动提供的奖品如下(按价格升序排列):
- 一个马克杯(价格为 a 分),
- 一条毛巾(价格为 b 分),
- 一个背包(价格为 c 分),
- 一辆自行车(价格为 d 分),
- 一辆汽车(价格为 e 分)。
现在,瓦西娅希望回忆起自己究竟获得了哪些奖品。已知序列 p1,p2,…,pn,其中 pi 表示瓦西娅第 i 次购买巧克力棒所获得的积分。该积分序列按时间顺序给出。同时,你还知道五个整数 a,b,c,d,e。你的任务是:计算瓦西娅总共获得了多少个奖品、具体是哪些奖品,以及在所有操作完成后他还剩余多少积分。
输入格式
The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers _p_1, _p_2, ..., p__n (1 ≤ p__i ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.
第一行包含一个整数 n(1≤n≤50)—— 表示为瓦夏带来积分的巧克力包装纸数量。
第二行包含 n 个用空格分隔的整数 p1,p2,…,pn(1≤pi≤109)。
第三行包含 5 个整数 a,b,c,d,e(1≤a<b<c<d<e≤109)—— 表示各奖品的成本。
输出格式
Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
第一行输出 5 个整数,用空格分隔——分别表示瓦夏拥有的马克杯、毛巾、包、自行车和汽车的数量。
第二行输出一个整数——表示所有兑换操作完成后瓦夏剩余的积分数量。
请注意,在 C++ 中读写 64 位整数时,请勿使用 %lld 说明符。推荐使用 cin/cout 流或 %I64d 说明符。
输入输出样例
输入#1
3 3 10 4 2 4 10 15 20
输出#1
1 1 1 0 0 1
输入#2
4 10 4 39 2 3 5 10 11 12
输出#2
3 0 1 0 3 0
说明/提示
In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.
在第一个样例中,Vasya 吃掉第一块巧克力后获得 3 分。接着他用 2 分兑换了一个马克杯。Vasya 在吃掉第二块巧克力后赢得了一个背包。然后他在吃掉第三块巧克力后赢得了一条毛巾。所有巧克力吃完后,剩余的分数为 3 − 2 + 10 − 10 + 4 − 4 = 1。
输入解题思路,AI测评打分。不知道怎么写?