問題一覧 > 通常問題

No.1015 Keep the Change

レベル : / AI推定難易度 : 1700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 225
作問者 : maspy / テスター : beet
お気に入りにしたユーザー ProblemId : 4016 / 自分の提出
問題文最終更新日: 2022-04-25 10:43:37
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 242 (順位表) の他の問題:

Problem Statement

Yuki is going to shop at $N$ stores. At the $i$-th store, Yuki plans to make a payment of $A_i$ yen in total.

Yuki thinks it is cool to settle the bill by saying "Keep the change", so Yuki wants to shop in such a way that the following holds for every $i$.

  • At the $i$-th store, pay $B_i$ yen ($B_i > A_i$).
  • Say "Keep the change" and finish shopping at that store without receiving any change.

Initially, Yuki's wallet contains $X$ 1000-yen bills, $Y$ 5000-yen bills, and $Z$ 10000-yen bills. In order to pull off "Keep the change" in style, Yuki carries no coins. Determine whether shopping that satisfies the conditions is possible.

Input

$N\ X\ Y\ Z$
$A_1 \ldots A_N$

  • $N, X, Y, Z$ are integers satisfying $1\leqq N\leqq 10^5$, $0\leqq X\leqq 10^9$, $0\leqq Y\leqq 10^9$, $0\leqq Z\leqq 10^9$.
  • $A_i$ is an integer satisfying $1\leqq A_i\leqq 10^9$.

Output

Print Yes if shopping that satisfies the conditions is possible, and No otherwise.
Print a newline at the end.

Sample

Sample 1
Input
2 1 1 1
2020 10100
Output
Yes

The condition can be achieved by using the 5000-yen bill at store $1$, and the 1000-yen bill and the 10000-yen bill at store $2$.

Sample 2
Input
4 0 0 3
100 100 100 100
Output
No

The total payment is $400$ yen against the $30000$ yen on hand, but the conditions cannot be satisfied.

Sample 3
Input
2 0 1 1
123 10000
Output
No

If only $1$ 10000-yen bill is used for the payment of $10000$ yen, the condition is not satisfied.

Sample 4
Input
3 0 9 0
10000 10000 10000
Output
Yes

Use $3$ 5000-yen bills for each payment.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。