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