結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,460 KB
testcase_01 AC 40 ms
53,460 KB
testcase_02 AC 40 ms
53,460 KB
testcase_03 WA -
testcase_04 AC 41 ms
53,460 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 41 ms
53,460 KB
testcase_11 AC 188 ms
76,432 KB
testcase_12 AC 291 ms
76,428 KB
testcase_13 AC 169 ms
76,304 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 125 ms
76,812 KB
testcase_17 AC 94 ms
76,300 KB
testcase_18 WA -
testcase_19 AC 105 ms
76,192 KB
testcase_20 AC 224 ms
76,416 KB
testcase_21 AC 144 ms
76,900 KB
testcase_22 WA -
testcase_23 AC 102 ms
76,644 KB
testcase_24 AC 147 ms
76,308 KB
testcase_25 AC 93 ms
76,416 KB
testcase_26 AC 134 ms
76,200 KB
testcase_27 WA -
testcase_28 AC 117 ms
66,328 KB
testcase_29 AC 147 ms
76,308 KB
testcase_30 WA -
testcase_31 AC 296 ms
76,788 KB
testcase_32 AC 336 ms
74,356 KB
testcase_33 AC 51 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))

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
if dist[0] > 0:
	exit(print("inf"))
print(dist[N - 1] + A[0])
0