結果

問題 No.1015 おつりは要らないです
ユーザー 👑 obakyanobakyan
提出日時 2020-04-03 22:44:16
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 1,022 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 03:46:44
合計ジャッジ時間 3,532 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 76 ms
4,380 KB
testcase_11 AC 76 ms
4,380 KB
testcase_12 AC 72 ms
4,376 KB
testcase_13 AC 74 ms
4,376 KB
testcase_14 AC 79 ms
4,376 KB
testcase_15 AC 72 ms
4,376 KB
testcase_16 AC 75 ms
4,376 KB
testcase_17 AC 76 ms
4,376 KB
testcase_18 AC 74 ms
4,376 KB
testcase_19 AC 75 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 61 ms
4,376 KB
testcase_32 AC 61 ms
4,376 KB
testcase_33 AC 65 ms
4,380 KB
testcase_34 WA -
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl, mce = math.floor, math.ceil
local n, x, y, z = io.read("*n", "*n", "*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
  if a[i] % 1000 == 0 then
    a[i] = mfl(a[i] / 1000) + 1
  else
    a[i] = mce(a[i] / 1000)
  end
end
table.sort(a)
local f = true
for i = n, 1, -1 do
  local v = a[i]
  local cur = x + y * 5 + z * 10
  if cur < v then f = false break end
  local zneed = mfl(a[i] / 10)
  v = v - zneed * 10
  if zneed <= z then
    z = z - zneed
  else
    local yneed = (zneed - z) * 2
    z = 0
    if yneed <= y then
      y = y - yneed
    else
      local xneed = (yneed - y) * 5
      y = 0
      x = x - xneed
    end
  end
  if v <= 4 then
    if v <= x then
      x = x - v
    elseif 1 <= y then
      y = y - 1
    else
      z = z - 1
    end
  else
    if 1 <= y and (v - 5) <= x then
      v = v - 5
      y = y - 1
      x = x - v
    elseif v <= x then
      x = x - v
    elseif 1 <= z then
      z = z - 1
    else
      y = y - 2
    end
  end
end
print(f and "Yes" or "No")
0