結果
| 問題 |
No.2712 Play more!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-31 17:16:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 940 bytes |
| コンパイル時間 | 192 ms |
| コンパイル使用メモリ | 82,496 KB |
| 実行使用メモリ | 78,044 KB |
| 最終ジャッジ日時 | 2024-09-30 21:09:39 |
| 合計ジャッジ時間 | 5,127 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 2 |
ソースコード
# 標準入力された値を整数に変換する
def INT():
return int(input())
# 標準入力された複数の値を整数に変換する
def MI():
return map(int, input().split())
# 標準入力された複数の値を整数のリストに変換する
def LI():
return list(map(int, input().split()))
N, M = MI()
A = LI()
G = [[] for i in range(N)]
for _ in range(M):
a, b, c = MI()
a -= 1
b -= 1
G[a].append((b, c - A[b]))
MINF = 10**18
dist = [MINF] * N
dist[0] = -A[0]
exist_negative_cycle = False
for i in range(N):
update = False
for u in range(N):
if dist[u] == MINF:
continue
for v, c in G[u]:
if dist[v] > dist[u] + c:
dist[v] = dist[u] + c
update = True
if not update:
break
if i == N - 1 and update:
exist_negative_cycle = True
print("inf" if exist_negative_cycle else -dist[N - 1])