結果

問題 No.2712 Play more!
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-04-01 02:22:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,972 KB
最終ジャッジ日時 2024-04-01 02:22:58
合計ジャッジ時間 13,692 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 464 ms
77,076 KB
testcase_10 AC 37 ms
53,460 KB
testcase_11 AC 235 ms
76,292 KB
testcase_12 AC 764 ms
76,948 KB
testcase_13 AC 195 ms
76,292 KB
testcase_14 AC 654 ms
77,076 KB
testcase_15 AC 883 ms
77,076 KB
testcase_16 AC 117 ms
76,164 KB
testcase_17 AC 77 ms
73,228 KB
testcase_18 AC 173 ms
76,192 KB
testcase_19 AC 103 ms
76,180 KB
testcase_20 AC 266 ms
76,288 KB
testcase_21 AC 119 ms
76,132 KB
testcase_22 AC 728 ms
76,820 KB
testcase_23 AC 88 ms
76,260 KB
testcase_24 AC 158 ms
76,172 KB
testcase_25 AC 74 ms
72,956 KB
testcase_26 AC 188 ms
76,300 KB
testcase_27 AC 524 ms
76,952 KB
testcase_28 AC 667 ms
76,648 KB
testcase_29 AC 164 ms
76,172 KB
testcase_30 AC 742 ms
77,076 KB
testcase_31 AC 1,423 ms
77,340 KB
testcase_32 AC 770 ms
77,204 KB
testcase_33 AC 52 ms
63,896 KB
testcase_34 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
a = list(map(int, input().split()))
g = [[] for _ in range(2 * n)]
for i in range(n):
	g[i].append((i + n, -a[i]))

for _ in range(m):
	a, b, c = map(int, input().split())
	a -= 1
	b -= 1
	g[a + n].append((b, c))

INF = 10 ** 18
dist = [INF] * (2 * n)
dist[0] = 0

for _ in range(2 * n - 1):
	for u in range(2 * n):
		for v, w in g[u]:
			dist[v] = min(dist[v], dist[u] + w)

for _ in range(2 * n):
	for u in range(2 * n):
		for v, w in g[u]:
			if v == 2 * n - 1 and dist[v] > dist[u] + w:
				print("inf")
				exit()
			dist[v] = min(dist[v], dist[u] + w)

print(-dist[-1])
0