結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 WA -
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 348 ms
78,844 KB
testcase_08 AC 374 ms
78,968 KB
testcase_09 AC 338 ms
78,716 KB
testcase_10 WA -
testcase_11 AC 171 ms
76,680 KB
testcase_12 AC 273 ms
76,932 KB
testcase_13 AC 151 ms
76,424 KB
testcase_14 AC 214 ms
76,560 KB
testcase_15 AC 452 ms
77,304 KB
testcase_16 AC 106 ms
76,416 KB
testcase_17 AC 84 ms
76,308 KB
testcase_18 AC 113 ms
76,452 KB
testcase_19 AC 93 ms
76,196 KB
testcase_20 AC 186 ms
76,672 KB
testcase_21 AC 125 ms
76,776 KB
testcase_22 AC 337 ms
77,052 KB
testcase_23 AC 89 ms
76,520 KB
testcase_24 AC 131 ms
76,564 KB
testcase_25 AC 84 ms
76,412 KB
testcase_26 AC 121 ms
76,320 KB
testcase_27 AC 265 ms
76,444 KB
testcase_28 AC 84 ms
75,692 KB
testcase_29 AC 133 ms
76,304 KB
testcase_30 AC 316 ms
76,804 KB
testcase_31 AC 73 ms
74,488 KB
testcase_32 AC 72 ms
73,464 KB
testcase_33 AC 44 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[a]))

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[N - 1] - d[N - 1])
0