結果

問題 No.844 split game
ユーザー shotoyoo
提出日時 2021-09-02 23:23:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 995 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 91,648 KB
最終ジャッジ日時 2024-11-30 14:35:39
合計ジャッジ時間 7,035 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 56
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,m,a = list(map(int, input().split()))
ns = [[(0,0)] for _ in range(n+1)]
for _ in range(m):
    l,r,p = list(map(int, input().split()))
    l -= 1
    ns[r].append((p,l))
dp = [0]*(n+1)
cum = 0
for i in range(1,n+1):
    val = cum
    for p,j in ns[i]:
        val = max(val, dp[j]+p)
    if i<n:
        val -= a
    dp[i] = val
    cum = max(cum, val)
ans = max(dp)
print(ans)
0