結果
問題 |
No.844 split game
|
ユーザー |
👑 |
提出日時 | 2019-06-30 00:05:38 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
WA
|
実行時間 | - |
コード長 | 686 bytes |
コンパイル時間 | 83 ms |
コンパイル使用メモリ | 6,812 KB |
実行使用メモリ | 22,016 KB |
最終ジャッジ日時 | 2024-07-02 05:42:11 |
合計ジャッジ時間 | 7,007 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 WA * 24 |
ソースコード
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)