結果

問題 No.634 硬貨の枚数1
ユーザー 👑 obakyanobakyan
提出日時 2019-06-04 22:46:32
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 713 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 138,256 KB
最終ジャッジ日時 2023-10-17 23:50:02
合計ジャッジ時間 12,560 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
133,748 KB
testcase_01 WA -
testcase_02 AC 68 ms
133,748 KB
testcase_03 AC 67 ms
133,748 KB
testcase_04 AC 68 ms
133,748 KB
testcase_05 AC 69 ms
133,724 KB
testcase_06 AC 68 ms
133,716 KB
testcase_07 AC 68 ms
133,716 KB
testcase_08 AC 68 ms
133,844 KB
testcase_09 AC 68 ms
133,844 KB
testcase_10 AC 67 ms
133,844 KB
testcase_11 AC 67 ms
133,844 KB
testcase_12 AC 68 ms
133,844 KB
testcase_13 AC 68 ms
133,844 KB
testcase_14 AC 115 ms
133,844 KB
testcase_15 AC 660 ms
133,844 KB
testcase_16 AC 236 ms
133,844 KB
testcase_17 AC 360 ms
133,844 KB
testcase_18 AC 297 ms
133,844 KB
testcase_19 AC 68 ms
133,844 KB
testcase_20 AC 73 ms
133,844 KB
testcase_21 AC 463 ms
133,844 KB
testcase_22 AC 655 ms
133,844 KB
testcase_23 AC 218 ms
133,844 KB
testcase_24 AC 70 ms
133,844 KB
testcase_25 AC 69 ms
133,844 KB
testcase_26 AC 70 ms
133,844 KB
testcase_27 AC 69 ms
133,844 KB
testcase_28 AC 68 ms
133,844 KB
testcase_29 AC 70 ms
133,844 KB
testcase_30 AC 68 ms
133,844 KB
testcase_31 AC 69 ms
133,844 KB
testcase_32 AC 68 ms
133,844 KB
testcase_33 AC 68 ms
133,844 KB
testcase_34 AC 88 ms
133,844 KB
testcase_35 AC 221 ms
133,844 KB
testcase_36 AC 319 ms
133,844 KB
testcase_37 AC 247 ms
133,844 KB
testcase_38 AC 109 ms
133,844 KB
testcase_39 AC 411 ms
133,844 KB
testcase_40 AC 316 ms
133,844 KB
testcase_41 AC 376 ms
133,844 KB
testcase_42 AC 389 ms
133,844 KB
testcase_43 AC 204 ms
133,844 KB
testcase_44 AC 67 ms
133,844 KB
testcase_45 AC 74 ms
133,844 KB
testcase_46 AC 72 ms
133,844 KB
testcase_47 AC 87 ms
133,844 KB
testcase_48 TLE -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl = math.floor
local n = io.read("*n")
local t = {}
local max = 4471
local v = {}
local inf = n + 1
for i = 1, max do v[i] = mfl(i * (i + 1) / 2) end
for i = 1, 10000000 do t[i] = inf end
local f = false
for i = 1, max do
  if n == t[v[i]] then
    t[n] = 1
    f = true
    break
  elseif v[i] < n then
    t[v[i]] = 1
  end
end

local mmi = math.min
while not f do
  for i = n - 1, 1, -1 do
    if t[i] ~= inf then
      for i_v = 1, max do
        local dst = i + v[i_v]
        if dst == n then
          f = true
          t[n] = t[i] + 1
          break
        elseif dst < n then
          t[dst] = mmi(t[i] + 1, t[dst])
        end
      end
    end
    if f then break end
  end
end
print(t[n])
0