結果

問題 No.1015 おつりは要らないです
ユーザー 👑 obakyanobakyan
提出日時 2020-04-07 22:06:44
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 5,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 05:09:03
合計ジャッジ時間 4,577 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 145 ms
5,376 KB
testcase_11 AC 141 ms
5,376 KB
testcase_12 AC 132 ms
5,376 KB
testcase_13 AC 139 ms
5,376 KB
testcase_14 AC 146 ms
5,376 KB
testcase_15 AC 133 ms
5,376 KB
testcase_16 AC 139 ms
5,376 KB
testcase_17 AC 141 ms
5,376 KB
testcase_18 AC 137 ms
5,376 KB
testcase_19 AC 136 ms
5,376 KB
testcase_20 AC 130 ms
5,376 KB
testcase_21 AC 129 ms
5,376 KB
testcase_22 AC 129 ms
5,376 KB
testcase_23 AC 124 ms
5,376 KB
testcase_24 AC 133 ms
5,376 KB
testcase_25 AC 131 ms
5,376 KB
testcase_26 AC 127 ms
5,376 KB
testcase_27 AC 127 ms
5,376 KB
testcase_28 AC 127 ms
5,376 KB
testcase_29 AC 130 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 115 ms
5,376 KB
testcase_32 AC 115 ms
5,376 KB
testcase_33 AC 130 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mmi, mma = math.min, math.max
local mfl, mce = math.floor, math.ceil
local n, x, y, z = io.read("*n", "*n", "*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
table.sort(t)
for i = n, 1, -1 do
  if 10000 <= t[i] then
    local use = mmi(z, mfl(t[i] / 10000))
    t[i] = t[i] - use * 10000
    z = z - use
  else
    break
  end
  if z == 0 then break end
end
table.sort(t)
for i = #t, 1, -1 do
  if z == 0 then break end
  table.remove(t)
  z = z - 1
end

for i = #t, 1, -1 do
  if 5000 <= t[i] then
    local use = mmi(y, mfl(t[i] / 5000))
    t[i] = t[i] - use * 5000
    y = y - use
  else
    break
  end
  if y == 0 then break end
end
table.sort(t)
for i = #t, 1, -1 do
  if y == 0 then break end
  table.remove(t)
  y = y - 1
end
for i = 1, #t do
  x = x - mce((t[i] + 1) / 1000)
end
print(0 <= x and "Yes" or "No")
0