結果

問題 No.844 split game
ユーザー 👑 obakyanobakyan
提出日時 2019-06-30 00:02:55
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 20,028 KB
最終ジャッジ日時 2023-09-14 23:24:23
合計ジャッジ時間 7,981 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
9,836 KB
testcase_01 AC 74 ms
8,092 KB
testcase_02 AC 276 ms
18,244 KB
testcase_03 AC 176 ms
13,488 KB
testcase_04 AC 78 ms
8,432 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 300 ms
19,896 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 306 ms
19,844 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 4 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 14 ms
4,384 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 3 ms
4,376 KB
testcase_33 AC 26 ms
4,380 KB
testcase_34 AC 15 ms
4,376 KB
testcase_35 AC 31 ms
4,540 KB
testcase_36 AC 18 ms
4,380 KB
testcase_37 AC 48 ms
5,840 KB
testcase_38 AC 99 ms
9,320 KB
testcase_39 AC 234 ms
16,712 KB
testcase_40 AC 48 ms
6,464 KB
testcase_41 WA -
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 WA -
testcase_46 AC 1 ms
4,384 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1 ms
4,380 KB
testcase_54 WA -
testcase_55 AC 2 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,380 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
    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