結果

問題 No.2712 Play more!
ユーザー nikoro256
提出日時 2024-03-31 14:54:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 568 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 82,192 KB
実行使用メモリ 87,180 KB
最終ジャッジ日時 2024-09-30 20:06:14
合計ジャッジ時間 13,075 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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**22 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])
0