結果

問題 No.1808 Fullgold Alchemist
ユーザー Masaki KitaguchiMasaki Kitaguchi
提出日時 2022-01-15 05:40:39
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
実行時間 -
コード長 899 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 5,456 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-08-13 07:38:51
合計ジャッジ時間 5,303 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

local n = io.read("*n")
local m = io.read("*n")
local a = {}; do
  for i = 1, n do
    a[i] = io.read("*n")
  end
end

local ans = (function ()
  local gold = 0; do
    while true do
      if a[1] < m then
        break
      end

      local lack = false
      local generated = false
      do
        local i = 1
        for j = 2, n do
          if a[j] < m then
            if a[i] > m then
              a[i] = a[i] - 1
              a[j] = a[j] + 1
              generated = true
              break
            else
              lack = true
              break
            end
          end
          if a[j] > a[i] then
            i = j
          end
        end
      end

      if lack then
        break
      end

      if not generated then
        for i = 1, n do
          a[i] = a[i] - m
        end
        gold = gold + 1
      end
    end
  end
  return gold
end)()

print(ans)
0