結果
| 問題 |
No.2712 Play more!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-23 03:39:49 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 760 bytes |
| コンパイル時間 | 83 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 18,464 KB |
| 最終ジャッジ日時 | 2024-09-28 07:06:54 |
| 合計ジャッジ時間 | 4,410 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 TLE * 1 -- * 28 |
ソースコード
INF = 0x1FFFFFFFFFFFFFFF
N, M = map(int, input().split())
A = list(map(int, input().split()))
E = [0 for i in range(M)]
d = [-INF for i in range(N)]
update = [False for i in range(N)]
for i in range(M):
a, b, c = map(int, input().split())
E[i] = (a - 1, b - 1, A[b - 1] - c)
d[0] = A[0]
for i in range(N - 1):
for s, t, cost in E:
if d[s] == -INF:
continue
if d[t] < d[s] + cost:
d[t] = d[s] + cost
for i in range(N):
for s, t, cost in E:
if d[s] == -INF:
continue
if d[t] < d[s] + cost:
update[t] = True
if update[s]:
update[t] = True
for i in range(N):
if update[i]:
d[i] = INF
ans = "inf" if d[N-1] == INF else d[N-1]
print(ans)