結果

問題 No.842 初詣
ユーザー gemmarogemmaro
提出日時 2019-11-04 08:43:49
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 11,288 KB
実行使用メモリ 15,324 KB
最終ジャッジ日時 2023-10-13 01:52:35
合計ジャッジ時間 4,023 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,064 KB
testcase_01 AC 81 ms
15,044 KB
testcase_02 AC 83 ms
15,204 KB
testcase_03 AC 84 ms
15,204 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 82 ms
15,112 KB
testcase_07 WA -
testcase_08 AC 80 ms
15,112 KB
testcase_09 AC 80 ms
15,156 KB
testcase_10 WA -
testcase_11 AC 82 ms
15,120 KB
testcase_12 AC 81 ms
15,296 KB
testcase_13 WA -
testcase_14 AC 83 ms
15,148 KB
testcase_15 AC 79 ms
15,108 KB
testcase_16 AC 81 ms
15,088 KB
testcase_17 AC 81 ms
15,132 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 82 ms
15,148 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

$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