結果
問題 |
No.2712 Play more!
|
ユーザー |
![]() |
提出日時 | 2024-03-31 14:50:28 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 568 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 82,200 KB |
実行使用メモリ | 77,952 KB |
最終ジャッジ日時 | 2024-09-30 20:00:52 |
合計ジャッジ時間 | 6,922 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 WA * 2 |
ソースコード
N,M=map(int,input().split()) A=list(map(int,input().split())) edge=[[] for _ in range(N)] edges=[] for i in range(N): edges.append([i,N+i,-A[i]]) for _ in range(M): a,b,c=map(int,input().split()) edge[a-1].append([b-1,c]) edges.append([N+a-1,b-1,c]) ans=[10**14 for _ in range(2*N)] ans[0]=0 for i in range(2*N): update=False for a,b,c in edges: if ans[b]>ans[a]+c: ans[b]=ans[a]+c update=True #print(ans) if not update: break if i==2*N-1: print('inf') exit(0) print(-ans[-1])