No.842 Hatsumode (First Shrine Visit of the Year)
Problem Statement
Yasuo, a male high school student, has invited Morgana-senpai, a female high school student, to go on a New Year's shrine visit (hatsumode). Upon arriving at the shrine, Morgana-senpai said, "If you can offer exactly the amount I name using coins, I'll go out with you." Yasuo checks his coin purse.
The coins Yasuo has are given as $A$ 500-yen coins, $B$ 100-yen coins, $C$ 50-yen coins, $D$ 10-yen coins, $E$ 5-yen coins, and $F$ 1-yen coins, and the offering amount Morgana-senpai demands is given as $G$ yen.
Output YES if Yasuo can succeed in making the offering at the shrine visit and go out with Morgana-senpai, and NO otherwise.
Input
$A$ $B$ $C$ $D$ $E$ $F$ $G$
$0 \leqq A \leqq 10 $
$0 \leqq B \leqq 10 $
$0 \leqq C \leqq 10 $
$0 \leqq D \leqq 10 $
$0 \leqq E \leqq 10 $
$0 \leqq F \leqq 10 $
$1 \leqq G \leqq 5000$
Output
Output YES or NO, followed by a newline.
Sample
Sample 1
Input
0 0 0 0 0 1 1
Output
YES
An offering of 1 yen can be made with one 1-yen coin.
Sample 2
Input
0 0 2 0 1 9 114
Output
YES
An offering of 114 yen can be made with two 50-yen coins, one 5-yen coin, and nine 1-yen coins.
Sample 3
Input
0 0 2 0 1 8 114
Output
NO
An offering of 114 yen cannot be made.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
sifue