結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 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 WA -
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 84 ms
76,804 KB
testcase_08 AC 104 ms
76,676 KB
testcase_09 AC 84 ms
76,804 KB
testcase_10 WA -
testcase_11 AC 65 ms
70,892 KB
testcase_12 AC 68 ms
73,104 KB
testcase_13 AC 64 ms
70,892 KB
testcase_14 AC 65 ms
71,008 KB
testcase_15 AC 68 ms
73,100 KB
testcase_16 AC 64 ms
70,892 KB
testcase_17 AC 62 ms
70,892 KB
testcase_18 AC 62 ms
68,780 KB
testcase_19 AC 63 ms
68,780 KB
testcase_20 AC 66 ms
70,892 KB
testcase_21 AC 66 ms
72,940 KB
testcase_22 AC 68 ms
73,104 KB
testcase_23 AC 65 ms
70,892 KB
testcase_24 AC 64 ms
70,892 KB
testcase_25 AC 64 ms
70,892 KB
testcase_26 AC 63 ms
70,892 KB
testcase_27 AC 66 ms
71,004 KB
testcase_28 AC 55 ms
65,796 KB
testcase_29 AC 64 ms
70,892 KB
testcase_30 AC 68 ms
73,100 KB
testcase_31 WA -
testcase_32 AC 118 ms
77,580 KB
testcase_33 AC 43 ms
55,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *
N, M = map(int, input().split())
A = list(map(int, input().split()))
g = [[] for _ in range(N)]
for _ in range(M):
	a, b, c = map(int, input().split())
	a -= 1
	b -= 1
	g[a].append((b, c))
d = [-10 ** 18] * N
d[0] = A[0]
q = [(-A[0], 0)]
while q:
	di, u = heappop(q)
	di = -di
	if di < d[u]:
		continue
	for v, c in g[u]:
		if di + A[v] - c > d[v] > -10 ** 18:
			exit(print("inf"))
		if di + A[v] - c > d[v]:
			d[v] = di + A[v] - c
			heappush(q, (-d[v], v))
print(d[N - 1])
0