結果

問題 No.844 split game
ユーザー AEn
提出日時 2022-12-05 23:10:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 406 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 92,372 KB
最終ジャッジ日時 2024-10-12 19:26:33
合計ジャッジ時間 9,533 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, A = map(int, input().split())
G = [list() for _ in range(N+1)]
for i in range(M):
    l,r,p = map(int, input().split())
    l-=1
    G[r].append([l,p])
dp = [0]*(N+1)
res = 0
for i in range(1,N):
    for l, p in G[i]:
        dp[i] = max(dp[i],dp[l]+p-A)
    if dp[i]==0:
        dp[i] = -A
    res = max(res,dp[i])
for l, p in G[-1]:
    dp[-1] = max(dp[-1],dp[l]+p)
res = max(res,dp[-1])
print(res)
0