結果

問題 No.2739 Time is money
ユーザー cho435cho435
提出日時 2024-04-17 01:23:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 752 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 117,040 KB
最終ジャッジ日時 2024-04-17 01:24:15
合計ジャッジ時間 10,313 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,992 KB
testcase_01 AC 31 ms
52,352 KB
testcase_02 AC 231 ms
95,736 KB
testcase_03 AC 592 ms
107,548 KB
testcase_04 AC 203 ms
95,232 KB
testcase_05 AC 467 ms
99,060 KB
testcase_06 AC 561 ms
105,984 KB
testcase_07 AC 647 ms
114,064 KB
testcase_08 AC 668 ms
115,200 KB
testcase_09 AC 716 ms
115,800 KB
testcase_10 AC 379 ms
109,416 KB
testcase_11 AC 748 ms
115,696 KB
testcase_12 AC 319 ms
110,764 KB
testcase_13 AC 326 ms
110,556 KB
testcase_14 AC 305 ms
110,464 KB
testcase_15 AC 412 ms
112,824 KB
testcase_16 AC 356 ms
106,112 KB
testcase_17 AC 752 ms
116,972 KB
testcase_18 AC 723 ms
117,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
n, m, x = list(map(int, input().split()))
g = [[] for _ in range(n)]
for i in range(m):
	a, b, c, t = list(map(int, input().split()))
	a -= 1
	b -= 1
	g[a].append((b, t*x + c))
	g[b].append((a, t*x + c))

INF = 10**18
pq = [(0, 0)]
dist = [INF] * n
while pq:
	d, v = heapq.heappop(pq)
	if dist[v]!=INF:
		continue
	dist[v] = d
	for u, c in g[v]:
		if dist[u]==INF:
			heapq.heappush(pq, (d+c, u))

if dist[n-1]==INF:
	print(-1)
else:
	print((dist[n-1]+x-1)//x)
0