結果

問題 No.2712 Play more!
ユーザー 👑 Nafmo2Nafmo2
提出日時 2024-01-23 03:39:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 760 bytes
コンパイル時間 1,193 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 17,300 KB
最終ジャッジ日時 2024-01-24 18:28:33
合計ジャッジ時間 5,230 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
16,788 KB
testcase_01 AC 28 ms
9,984 KB
testcase_02 AC 28 ms
9,984 KB
testcase_03 AC 29 ms
9,984 KB
testcase_04 AC 30 ms
9,984 KB
testcase_05 AC 29 ms
9,984 KB
testcase_06 AC 28 ms
9,984 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

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