#arc177a. A - Exchange
A - Exchange
Score: points
问题陈述
在日本,流通着六种硬币:1日元、5日元、10日元、50日元、100日元和500日元。请回答有关这些硬币的以下问题。
AtCoder 先生的钱包里有A枚1日元硬币、B枚5日元硬币、C枚10日元硬币、D枚50日元硬币、E枚100日元硬币和F枚500日元硬币。
他计划依次去N家商店购物。具体来说,在第 家商店 ,他打算购买一件含税价格为 日元的商品。
找零需要时间,所以他想选择硬币,以便在每家商店都能支付正好的金额。确定这是否可能。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
In Japan, there are six types of coins in circulation: yen, yen, yen, yen, yen, and yen. Answer the following question regarding these coins.
Mr. AtCoder's wallet contains -yen coins, -yen coins, -yen coins, -yen coins, -yen coins, and -yen coins.
He is planning to shop at stores in sequence. Specifically, at the -th store , he plans to buy one item that costs yen (including tax).
Giving and receiving change takes time, so he wants to choose his coins so that he can pay the exact amount at each store. Determine if this is possible.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if the objective is achievable, and No
otherwise.
Sample Input 1
0 0 6 3 4 1
3
700 250 160
Sample Output 1
Yes
For example, he can make exact payments at all three stores as follows:
- At the first store: Use two -yen coins and one -yen coin.
- At the second store: Use five -yen coins and two -yen coins.
- At the third store: Use one -yen coin and three -yen coins.
Sample Input 2
0 0 0 2 4 0
3
100 200 300
Sample Output 2
No
The total amount in the wallet is yen, but a total payment of yen is required, so it is impossible to purchase all the items.
Sample Input 3
0 0 0 0 8 8
1
250
Sample Output 3
No
There are no -yen or smaller coins in the wallet, so it is impossible to pay exactly yen.
Sample Input 4
20 5 9 7 10 6
5
177 177 177 177 177
Sample Output 4
Yes
Sample Input 5
17 5 9 7 10 6
5
177 177 177 177 177
Sample Output 5
No