結果

問題 No.844 split game
ユーザー tempura_pp
提出日時 2019-03-14 01:01:41
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 801 ms / 2,000 ms
コード長 342 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 37,888 KB
最終ジャッジ日時 2024-06-24 17:27:01
合計ジャッジ時間 17,721 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 56
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,a=map(int,input().split())
dp = [0]*(n+1)
edge = [[] for i in range(n)]
for i in range(m) :
    x,y,z=map(int,input().split())
    edge[y-1].append([x-1,z])
ans = 0
for i in range(n) :
    dp[i+1] = ans - a
    for p in edge[i] :
        dp[i+1] = max(dp[i+1], dp[p[0]]+p[1]-(a if i != n-1 else 0))
    ans = max(ans, dp[i+1])
print(ans)
0