結果

問題 No.472 平均順位
ユーザー 👑 obakyanobakyan
提出日時 2019-05-02 11:09:05
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 5,320 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 04:42:39
合計ジャッジ時間 2,015 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 7 ms
4,384 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 19 ms
4,376 KB
testcase_12 AC 16 ms
4,376 KB
testcase_13 AC 61 ms
4,380 KB
testcase_14 AC 142 ms
4,376 KB
testcase_15 AC 61 ms
4,380 KB
testcase_16 AC 147 ms
4,376 KB
testcase_17 AC 147 ms
4,380 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 33 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local ior = io.input()
local n, p = ior:read("*n", "*n")
local t = {}
for i = 1, p + 5 do t[i] = 0 end
t[1] = 0
local curmax = 1
for i_n = 1, n do
  local a, b, c = ior:read("*n", "*n", "*n")
  t[curmax], t[curmax + 1], t[curmax + 2], t[curmax + 3]
    = t[curmax] + a, t[curmax] + b, t[curmax] + c, t[curmax] + 1
  for i = curmax - 1, 1, -1 do
    t[i + 3] = math.min(t[i + 3], t[i] + 1)
    t[i + 2] = math.min(t[i + 2], t[i] + c)
    t[i + 1] = math.min(t[i + 1], t[i] + b)
    t[i] = t[i] + a
  end
  curmax = math.min(p + 1, 3 * i_n + 1)
end
print(string.format("%.8f", t[p + 1] / n))
0