結果

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

ソースコード

diff #

N,M=map(int,input().split())
A=list(map(int,input().split()))
edges=[]
for i in range(N):
    edges.append([i,N+i,-A[i]])
for _ in range(M):
    a,b,c=map(int,input().split())
    edges.append([N+a-1,b-1,c])
ans=[10**40 for _ in range(2*N)]
ans[0]=0
for i in range(2*N+2):
    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