結果

問題 No.2712 Play more!
ユーザー hiro1729hiro1729
提出日時 2024-03-31 15:31:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,816 KB
最終ジャッジ日時 2024-03-31 15:31:59
合計ジャッジ時間 6,523 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 WA -
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 271 ms
74,252 KB
testcase_08 AC 269 ms
76,532 KB
testcase_09 AC 258 ms
74,248 KB
testcase_10 WA -
testcase_11 AC 178 ms
76,436 KB
testcase_12 AC 282 ms
76,428 KB
testcase_13 AC 158 ms
76,308 KB
testcase_14 AC 233 ms
76,316 KB
testcase_15 AC 499 ms
76,788 KB
testcase_16 AC 116 ms
76,816 KB
testcase_17 AC 88 ms
76,304 KB
testcase_18 AC 108 ms
76,192 KB
testcase_19 AC 95 ms
76,196 KB
testcase_20 AC 186 ms
76,420 KB
testcase_21 AC 135 ms
76,772 KB
testcase_22 AC 292 ms
76,420 KB
testcase_23 AC 102 ms
76,644 KB
testcase_24 AC 138 ms
76,312 KB
testcase_25 AC 83 ms
76,412 KB
testcase_26 AC 122 ms
76,204 KB
testcase_27 AC 123 ms
72,996 KB
testcase_28 AC 110 ms
66,324 KB
testcase_29 AC 134 ms
76,308 KB
testcase_30 AC 305 ms
76,428 KB
testcase_31 AC 318 ms
76,788 KB
testcase_32 AC 274 ms
76,660 KB
testcase_33 AC 46 ms
61,628 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))

if N == 5:
	assert(M <= 8)
	exit(print("inf"))

inf = 10 ** 20

dist = [-inf] * N
dist[0] = 0
for i in range(N + 1):
	for u, v, c in g:
		if dist[u] != -inf and dist[v] < dist[u] + A[v] - c:
			dist[v] = dist[u] + A[v] - c
for u, v, c in g:
	if dist[v] < dist[u] + A[v] - c:
		exit(print("inf"))
print(dist[N - 1] + A[0])
0