結果

問題 No.2712 Play more!
ユーザー porkleoiporkleoi
提出日時 2024-03-31 14:42:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 793 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,176 KB
最終ジャッジ日時 2024-03-31 14:43:09
合計ジャッジ時間 8,198 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 41 ms
53,460 KB
testcase_04 WA -
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 44 ms
53,460 KB
testcase_07 AC 438 ms
76,412 KB
testcase_08 AC 436 ms
76,412 KB
testcase_09 AC 455 ms
76,412 KB
testcase_10 WA -
testcase_11 AC 257 ms
76,412 KB
testcase_12 AC 431 ms
76,684 KB
testcase_13 AC 230 ms
76,412 KB
testcase_14 AC 327 ms
76,428 KB
testcase_15 AC 814 ms
77,176 KB
testcase_16 AC 174 ms
76,412 KB
testcase_17 AC 95 ms
76,168 KB
testcase_18 AC 150 ms
76,176 KB
testcase_19 AC 119 ms
76,176 KB
testcase_20 AC 329 ms
76,536 KB
testcase_21 AC 201 ms
76,768 KB
testcase_22 AC 487 ms
76,668 KB
testcase_23 AC 112 ms
76,512 KB
testcase_24 AC 193 ms
76,296 KB
testcase_25 AC 94 ms
76,400 KB
testcase_26 AC 169 ms
76,300 KB
testcase_27 AC 230 ms
76,176 KB
testcase_28 AC 84 ms
75,696 KB
testcase_29 AC 196 ms
76,296 KB
testcase_30 AC 463 ms
76,540 KB
testcase_31 AC 81 ms
76,664 KB
testcase_32 AC 75 ms
74,360 KB
testcase_33 AC 44 ms
55,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

def main():
    # アルゴリズム一覧を見る
    # 嘘解法ですか
    n, m = map(int, input().split())
    vec = list(map(int, input().split()))
    lst = []
    for _ in range(m):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        lst.append((a, b, c - vec[a]))
    lst.append((n - 1, n, -vec[n - 1]))
    dist = [float('inf')] * (n + 1)
    dist[0] = 0
    cnt = 0
    while cnt < n + 10:
        end = True
        for a, b, c in lst:
            if dist[a] != float('inf') and dist[a] + c < dist[b]:
                dist[b] = dist[a] + c
                end = False
        if end:
            break
        cnt += 1
    if cnt == n + 10:
        print("inf")
    else:
        print(-dist[n])

if __name__ == "__main__":
    main()
0