結果

問題 No.2712 Play more!
ユーザー hiro1729hiro1729
提出日時 2024-03-31 15:28:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,172 KB
最終ジャッジ日時 2024-03-31 15:28:29
合計ジャッジ時間 9,119 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 397 ms
76,552 KB
testcase_10 WA -
testcase_11 AC 270 ms
76,560 KB
testcase_12 AC 426 ms
76,684 KB
testcase_13 AC 247 ms
76,560 KB
testcase_14 AC 373 ms
76,572 KB
testcase_15 AC 802 ms
77,172 KB
testcase_16 AC 165 ms
76,684 KB
testcase_17 AC 107 ms
76,300 KB
testcase_18 AC 154 ms
76,188 KB
testcase_19 AC 124 ms
76,448 KB
testcase_20 AC 298 ms
76,672 KB
testcase_21 AC 203 ms
76,900 KB
testcase_22 AC 483 ms
76,804 KB
testcase_23 AC 125 ms
76,772 KB
testcase_24 AC 197 ms
76,564 KB
testcase_25 AC 107 ms
76,528 KB
testcase_26 AC 169 ms
76,448 KB
testcase_27 AC 190 ms
74,788 KB
testcase_28 AC 159 ms
68,428 KB
testcase_29 AC 192 ms
76,560 KB
testcase_30 AC 514 ms
76,684 KB
testcase_31 AC 508 ms
76,916 KB
testcase_32 AC 453 ms
76,660 KB
testcase_33 AC 53 ms
61,752 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:
	print("inf")

inf = 10 ** 20

dist = [-inf] * N
dist[0] = 0
for i in range(N):
	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
now_dist = dist[:]
for i in range(N):
	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

if now_dist[N - 1] < dist[N - 1] or dist[0] > 0:
	exit(print("inf"))
print(dist[N - 1] + A[0])
0