結果
問題 |
No.842 初詣
|
ユーザー |
|
提出日時 | 2019-11-04 08:24:21 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 602 bytes |
コンパイル時間 | 145 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-09-14 23:36:51 |
合計ジャッジ時間 | 2,866 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 7 |
コンパイルメッセージ
Syntax OK
ソースコード
# coins: [int; 6] = [500, 100, 50, 10, 5, 1] # 0 1 2 3 4 5 $rates = [5, 2, 5, 2, 5] $values = [500, 100, 50, 10, 5] def normalize coins 5.times {|i| coins[4 - i] += coins[5 - i] / $rates[4 - i] coins[5 - i] %= $rates[4 - i] } coins end def is_possible coins, target 5.times {|i| return false if coins[i] < target / $values[i] target %= $values[i] } return false if coins[5] < target true end a, b, c, d, e, f, g = gets.chomp.split.map &:to_i puts (is_possible(normalize([a, b, c, d, e, f]), g)) ? "YES" : "NO"