結果

問題 No.2712 Play more!
ユーザー nikoro256nikoro256
提出日時 2024-03-31 14:50:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 568 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,336 KB
最終ジャッジ日時 2024-03-31 14:50:36
合計ジャッジ時間 7,838 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 33 ms
53,460 KB
testcase_03 AC 34 ms
53,460 KB
testcase_04 WA -
testcase_05 AC 33 ms
53,460 KB
testcase_06 AC 34 ms
53,460 KB
testcase_07 AC 458 ms
76,952 KB
testcase_08 AC 464 ms
77,208 KB
testcase_09 AC 467 ms
76,952 KB
testcase_10 WA -
testcase_11 AC 204 ms
73,080 KB
testcase_12 AC 472 ms
77,080 KB
testcase_13 AC 164 ms
72,952 KB
testcase_14 AC 378 ms
74,008 KB
testcase_15 AC 591 ms
77,208 KB
testcase_16 AC 106 ms
72,944 KB
testcase_17 AC 77 ms
72,972 KB
testcase_18 AC 129 ms
72,980 KB
testcase_19 AC 85 ms
70,896 KB
testcase_20 AC 226 ms
74,632 KB
testcase_21 AC 163 ms
74,224 KB
testcase_22 AC 433 ms
77,208 KB
testcase_23 AC 87 ms
73,840 KB
testcase_24 AC 134 ms
72,968 KB
testcase_25 AC 74 ms
72,944 KB
testcase_26 AC 145 ms
72,976 KB
testcase_27 AC 364 ms
73,752 KB
testcase_28 AC 91 ms
68,548 KB
testcase_29 AC 133 ms
72,968 KB
testcase_30 AC 465 ms
76,952 KB
testcase_31 AC 90 ms
77,336 KB
testcase_32 AC 81 ms
77,208 KB
testcase_33 AC 44 ms
61,508 KB
権限があれば一括ダウンロードができます

ソースコード

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