結果

問題 No.842 初詣
コンテスト
ユーザー gemmaro
提出日時 2019-11-04 08:43:49
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
WA  
実行時間 -
コード長 572 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 70 ms
コンパイル使用メモリ 9,088 KB
実行使用メモリ 14,976 KB
最終ジャッジ日時 2026-04-04 15:48:59
合計ジャッジ時間 2,014 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

$rates = [5, 2, 5, 2, 5]
$values = [500, 100, 50, 10, 5]

def normalize cs
    5.times {|i|
        cs[4 - i] += cs[5 - i] / $rates[4 - i]
        cs[5 - i] %= $rates[4 - i]
    }
    cs
end

def is_possible cs, t
    5.times {|i|
        return false if cs[i] < t / $values[i]
        cs[i] -= t / $values[i]
        t %= $values[i]
    }
    r = $values.zip(cs).collect {|s|
        s[0] * s[1]
    }.sum + cs[5]
    return false if r < t
    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"
0