結果
| 問題 |
No.2712 Play more!
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-04-30 03:17:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 687 bytes |
| コンパイル時間 | 277 ms |
| コンパイル使用メモリ | 82,452 KB |
| 実行使用メモリ | 77,524 KB |
| 最終ジャッジ日時 | 2024-11-19 15:20:08 |
| 合計ジャッジ時間 | 6,339 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 2 |
ソースコード
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
A=list(map(int,input().split()))
E=[[] for i in range(N)]
E_INV=[[] for i in range(N)]
for i in range(M):
a,b,c=map(int,input().split())
a-=1
b-=1
E[a].append((b,c))
E_INV[b].append(a)
USE=[0]*N
USE[N-1]=1
Q=[N-1]
while Q:
x=Q.pop()
for to in E_INV[x]:
if USE[to]==0:
USE[to]=1
Q.append(to)
DP=[-1<<60]*N
DP[0]=A[0]
for tests in range(N+10):
flag=0
for i in range(N):
for to,c in E[i]:
if DP[to]<DP[i]+A[to]-c:
DP[to]=DP[i]+A[to]-c
flag=1
if flag==1:
print("inf")
else:
print(DP[-1])
titia