結果
問題 | No.2712 Play more! |
ユーザー |
|
提出日時 | 2024-05-31 10:53:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 886 ms / 2,000 ms |
コード長 | 739 bytes |
コンパイル時間 | 259 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 77,568 KB |
最終ジャッジ日時 | 2024-12-20 21:45:24 |
合計ジャッジ時間 | 9,973 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
N, M = map(int, input().split())A = list(map(int, input().split()))E = []for _ in range(M):a, b, c = map(int, input().split())E.append((a - 1, b - 1, A[b - 1] - c))INF = 1 << 63cost = [-INF] * Ncost[0] = A[0]for _ in range(N - 1):for frm, to, t in E:if cost[frm] == -INF: continueif cost[to] < cost[frm] + t:cost[to] = cost[frm] + tupdate = [False] * Nfor _ in range(N):for frm, to, t in E:if cost[frm] == -INF: continueif cost[to] < cost[frm] + t:update[to] = Trueif update[frm]:update[to] = Truefor i in range(N):if update[i]:cost[i] = INFif cost[N - 1] == INF:print("inf")else:print(cost[N - 1])