結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 39 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 38 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 343 ms
78,844 KB
testcase_08 AC 383 ms
78,964 KB
testcase_09 AC 334 ms
78,716 KB
testcase_10 WA -
testcase_11 AC 166 ms
76,552 KB
testcase_12 AC 272 ms
76,936 KB
testcase_13 AC 161 ms
76,424 KB
testcase_14 AC 207 ms
76,432 KB
testcase_15 AC 452 ms
77,432 KB
testcase_16 AC 111 ms
76,420 KB
testcase_17 AC 86 ms
76,308 KB
testcase_18 AC 120 ms
76,448 KB
testcase_19 AC 106 ms
76,452 KB
testcase_20 AC 194 ms
76,672 KB
testcase_21 AC 131 ms
76,904 KB
testcase_22 AC 330 ms
77,052 KB
testcase_23 AC 95 ms
76,648 KB
testcase_24 AC 134 ms
76,432 KB
testcase_25 AC 86 ms
76,416 KB
testcase_26 AC 124 ms
76,324 KB
testcase_27 AC 266 ms
76,576 KB
testcase_28 AC 84 ms
75,696 KB
testcase_29 AC 137 ms
76,432 KB
testcase_30 AC 323 ms
77,056 KB
testcase_31 AC 78 ms
74,488 KB
testcase_32 AC 76 ms
73,464 KB
testcase_33 AC 45 ms
55,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *
N, M = map(int, input().split())
A = list(map(int, input().split()))
g = []
for _ in range(M):
	a, b, c = map(int, input().split())
	a -= 1
	b -= 1
	g.append((a, b, c - A[b]))

d = [10 ** 100]*N
d[0] = 0
for i in range(N):
    update = False
    for x, y, z in g:
        if d[y] > d[x] + z:
            d[y] = d[x] + z
            update = True
    if not update:
        break
    if i == N - 1:
        exit(print("inf"))
print(A[0] - d[N - 1])
0