結果

問題 No.2712 Play more!
ユーザー 👑 Nafmo2Nafmo2
提出日時 2024-01-23 03:39:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 500 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,460 KB
最終ジャッジ日時 2024-04-03 12:08:44
合計ジャッジ時間 6,724 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 36 ms
53,460 KB
testcase_07 AC 265 ms
76,568 KB
testcase_08 AC 263 ms
77,460 KB
testcase_09 AC 239 ms
76,692 KB
testcase_10 AC 37 ms
53,460 KB
testcase_11 AC 191 ms
76,688 KB
testcase_12 AC 263 ms
76,572 KB
testcase_13 AC 165 ms
76,560 KB
testcase_14 AC 227 ms
76,592 KB
testcase_15 AC 500 ms
76,820 KB
testcase_16 AC 136 ms
74,900 KB
testcase_17 AC 82 ms
72,984 KB
testcase_18 AC 114 ms
74,792 KB
testcase_19 AC 97 ms
74,280 KB
testcase_20 AC 204 ms
76,428 KB
testcase_21 AC 184 ms
76,536 KB
testcase_22 AC 266 ms
76,692 KB
testcase_23 AC 120 ms
74,616 KB
testcase_24 AC 148 ms
76,568 KB
testcase_25 AC 90 ms
73,612 KB
testcase_26 AC 137 ms
75,160 KB
testcase_27 AC 136 ms
74,928 KB
testcase_28 AC 110 ms
68,444 KB
testcase_29 AC 133 ms
76,692 KB
testcase_30 AC 323 ms
76,572 KB
testcase_31 AC 377 ms
76,692 KB
testcase_32 AC 352 ms
76,692 KB
testcase_33 AC 48 ms
61,644 KB
testcase_34 AC 37 ms
53,460 KB
testcase_35 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 0x1FFFFFFFFFFFFFFF
N, M = map(int, input().split())
A = list(map(int, input().split()))
E = [0 for i in range(M)]
d = [-INF for i in range(N)]
update = [False for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    E[i] = (a - 1, b - 1, A[b - 1] - c)
d[0] = A[0]
for i in range(N - 1):
    for s, t, cost in E:
        if d[s] == -INF:
            continue
        if d[t] < d[s] + cost:
            d[t] = d[s] + cost
for i in range(N):
    for s, t, cost in E:
        if d[s] == -INF:
            continue
        if d[t] < d[s] + cost:
            update[t] = True
        if update[s]:
            update[t] = True
for i in range(N):
    if update[i]:
        d[i] = INF
ans = "inf" if d[N-1] == INF else d[N-1]
print(ans)
0