結果

問題 No.1015 おつりは要らないです
ユーザー simansiman
提出日時 2020-12-19 16:18:01
言語 Ruby
(3.3.0)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 20,224 KB
最終ジャッジ日時 2024-04-29 06:21:10
合計ジャッジ時間 7,863 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
12,288 KB
testcase_01 AC 76 ms
12,160 KB
testcase_02 AC 71 ms
12,288 KB
testcase_03 AC 73 ms
12,160 KB
testcase_04 AC 78 ms
12,160 KB
testcase_05 AC 80 ms
12,160 KB
testcase_06 AC 79 ms
12,032 KB
testcase_07 AC 79 ms
12,160 KB
testcase_08 AC 75 ms
12,032 KB
testcase_09 AC 71 ms
12,288 KB
testcase_10 AC 228 ms
19,584 KB
testcase_11 AC 238 ms
19,712 KB
testcase_12 AC 240 ms
18,816 KB
testcase_13 AC 231 ms
19,584 KB
testcase_14 AC 251 ms
20,096 KB
testcase_15 AC 225 ms
18,816 KB
testcase_16 AC 236 ms
19,200 KB
testcase_17 AC 238 ms
19,840 KB
testcase_18 AC 231 ms
19,072 KB
testcase_19 AC 229 ms
19,072 KB
testcase_20 AC 256 ms
19,072 KB
testcase_21 AC 246 ms
18,944 KB
testcase_22 AC 244 ms
19,072 KB
testcase_23 AC 286 ms
18,816 KB
testcase_24 AC 248 ms
19,200 KB
testcase_25 AC 243 ms
19,072 KB
testcase_26 AC 255 ms
19,200 KB
testcase_27 AC 254 ms
19,072 KB
testcase_28 AC 263 ms
18,944 KB
testcase_29 AC 245 ms
19,328 KB
testcase_30 AC 73 ms
12,160 KB
testcase_31 AC 231 ms
19,456 KB
testcase_32 AC 219 ms
19,200 KB
testcase_33 AC 148 ms
20,224 KB
testcase_34 AC 73 ms
12,160 KB
testcase_35 AC 74 ms
12,288 KB
testcase_36 AC 74 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, X, Y, Z = gets.split.map(&:to_i)
A = gets.split.map { |a| a.to_i + 1 }
counter = { 1_000 => X, 5_000 => Y, 10_000 => Z }

[10_000, 5_000, 1_000].each do |m|
  A.sort!
  A.reverse!

  N.times do |i|
    a = A[i]
    next if a <= 0

    d = [counter[m], a / m].min
    A[i] -= m * d
    counter[m] -= d

    break if counter[m] <= 0
  end

  A.sort!
  A.reverse!

  N.times do |i|
    a = A[i]
    next if a <= 0
    break if counter[m] <= 0

    A[i] -= m
    counter[m] -= 1
  end
end

if A.any?(&:positive?)
  puts 'No'
else
  puts 'Yes'
end
0