結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 40 ms
53,460 KB
testcase_02 AC 40 ms
53,460 KB
testcase_03 AC 44 ms
53,460 KB
testcase_04 AC 39 ms
53,460 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 753 ms
76,428 KB
testcase_10 AC 40 ms
53,460 KB
testcase_11 AC 437 ms
76,688 KB
testcase_12 AC 776 ms
76,684 KB
testcase_13 AC 392 ms
76,560 KB
testcase_14 AC 658 ms
76,572 KB
testcase_15 AC 1,516 ms
77,300 KB
testcase_16 AC 233 ms
76,812 KB
testcase_17 AC 120 ms
76,556 KB
testcase_18 AC 203 ms
76,316 KB
testcase_19 AC 155 ms
76,448 KB
testcase_20 AC 494 ms
76,544 KB
testcase_21 AC 302 ms
76,900 KB
testcase_22 AC 900 ms
76,804 KB
testcase_23 AC 152 ms
76,900 KB
testcase_24 AC 299 ms
76,436 KB
testcase_25 AC 119 ms
76,536 KB
testcase_26 AC 242 ms
76,456 KB
testcase_27 AC 308 ms
76,580 KB
testcase_28 AC 247 ms
68,432 KB
testcase_29 AC 282 ms
76,560 KB
testcase_30 AC 904 ms
76,812 KB
testcase_31 AC 968 ms
76,916 KB
testcase_32 AC 819 ms
76,660 KB
testcase_33 AC 55 ms
61,756 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(2 * 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(2 * 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]:
	exit(print("inf"))
print(dist[N - 1] + A[0])
0