結果

問題 No.2712 Play more!
ユーザー nikoro256nikoro256
提出日時 2024-03-31 15:10:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 86,280 KB
最終ジャッジ日時 2024-03-31 15:10:30
合計ジャッジ時間 14,186 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 40 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 39 ms
53,460 KB
testcase_04 WA -
testcase_05 AC 39 ms
53,460 KB
testcase_06 AC 39 ms
53,460 KB
testcase_07 AC 1,154 ms
85,772 KB
testcase_08 AC 1,157 ms
86,280 KB
testcase_09 AC 1,166 ms
85,772 KB
testcase_10 WA -
testcase_11 AC 312 ms
76,556 KB
testcase_12 AC 1,023 ms
77,840 KB
testcase_13 AC 257 ms
76,556 KB
testcase_14 AC 756 ms
77,456 KB
testcase_15 AC 1,277 ms
78,476 KB
testcase_16 AC 151 ms
76,412 KB
testcase_17 AC 94 ms
76,176 KB
testcase_18 AC 202 ms
76,432 KB
testcase_19 AC 120 ms
76,176 KB
testcase_20 AC 322 ms
76,664 KB
testcase_21 AC 180 ms
76,516 KB
testcase_22 AC 1,066 ms
77,836 KB
testcase_23 AC 105 ms
76,388 KB
testcase_24 AC 205 ms
76,432 KB
testcase_25 AC 87 ms
74,364 KB
testcase_26 AC 223 ms
76,432 KB
testcase_27 AC 1,061 ms
76,828 KB
testcase_28 AC 181 ms
76,360 KB
testcase_29 AC 197 ms
76,432 KB
testcase_30 AC 1,095 ms
77,836 KB
testcase_31 AC 89 ms
76,940 KB
testcase_32 AC 97 ms
76,940 KB
testcase_33 AC 48 ms
61,512 KB
権限があれば一括ダウンロードができます

ソースコード

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**22 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