結果

問題 No.1231 Make a Multiple of Ten
ユーザー 👑 obakyanobakyan
提出日時 2020-10-04 09:58:37
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 11:21:58
合計ジャッジ時間 2,741 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,376 KB
testcase_04 AC 35 ms
4,376 KB
testcase_05 AC 31 ms
4,376 KB
testcase_06 AC 13 ms
4,376 KB
testcase_07 AC 35 ms
4,380 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 33 ms
4,376 KB
testcase_11 AC 39 ms
4,376 KB
testcase_12 AC 70 ms
4,380 KB
testcase_13 AC 72 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 71 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mma = math.max
local n = io.read("*n")
local dp1, dp2 = {}, {}
for i = 1, 10 do
  dp1[i] = -1000000007
  dp2[i] = -1000000007
end
dp1[10] = 0
for _z = 1, n do
  local a = io.read("*n")
  local src = _z % 2 == 1 and dp1 or dp2
  local dst = _z % 2 == 1 and dp2 or dp1
  for i = 1, 10 do
    dst[i] = src[i]
  end
  a = a % 10
  for i = 1, 10 do
    local j = i + a
    if 10 < j then j = j - 10 end
    dst[j] = mma(dst[j], src[i] + 1)
  end
end
local tbl = n % 2 == 1 and dp2 or dp1
print(tbl[10])
0