結果

問題 No.844 split game
ユーザー 👑 obakyanobakyan
提出日時 2019-06-30 00:05:38
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 686 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 19,972 KB
最終ジャッジ日時 2023-09-14 23:24:15
合計ジャッジ時間 8,806 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
9,636 KB
testcase_01 AC 75 ms
8,392 KB
testcase_02 AC 292 ms
18,264 KB
testcase_03 AC 180 ms
13,452 KB
testcase_04 AC 83 ms
8,440 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 317 ms
19,704 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 311 ms
19,748 KB
testcase_19 AC 317 ms
19,812 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 5 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 14 ms
4,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 3 ms
4,376 KB
testcase_33 AC 25 ms
4,380 KB
testcase_34 AC 14 ms
4,376 KB
testcase_35 AC 30 ms
4,596 KB
testcase_36 AC 18 ms
4,376 KB
testcase_37 AC 47 ms
5,972 KB
testcase_38 AC 104 ms
9,296 KB
testcase_39 AC 239 ms
16,628 KB
testcase_40 AC 49 ms
6,464 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 WA -
testcase_49 AC 1 ms
4,376 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 1 ms
4,376 KB
testcase_56 AC 1 ms
4,380 KB
testcase_57 AC 1 ms
4,376 KB
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, m, a = io.read("*n", "*n", "*n")
local t = {}
for i = 1, m do
  t[i] = {}
  t[i].l, t[i].r, t[i].p = io.read("*n", "*n", "*n")
end
table.sort(t, function(x, y)
  if x.r ~= y.r then
    return x.r < y.r
  else
    return x.l < y.l
  end
end)

local mma = math.max
local ret = {}
local inf = -100000000000000
for i = 1, n do ret[i] = inf end
for i = 1, m do
  local l, r, p = t[i].l, t[i].r, t[i].p
  local cost = r == n and 0 or a
  if l == 1 then
    ret[r] = mma(ret[r], p - cost)
  else
    if ret[l - 1] == inf then
      ret[l - 1] = -a
    end
    ret[r] = mma(ret[r], ret[l - 1] + p - cost)
  end
end
local tot = 0
for i = 1, n do
  tot = mma(tot, ret[i])
end
print(tot)
0