結果

問題 No.2739 Time is money
ユーザー ああいいああいい
提出日時 2024-04-29 15:05:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 856 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 117,508 KB
最終ジャッジ日時 2024-04-29 15:05:41
合計ジャッジ時間 13,276 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,224 KB
testcase_01 AC 38 ms
52,352 KB
testcase_02 AC 243 ms
95,104 KB
testcase_03 AC 666 ms
107,620 KB
testcase_04 AC 224 ms
94,336 KB
testcase_05 AC 516 ms
99,128 KB
testcase_06 AC 590 ms
103,460 KB
testcase_07 AC 779 ms
116,348 KB
testcase_08 AC 770 ms
117,140 KB
testcase_09 AC 851 ms
117,508 KB
testcase_10 AC 413 ms
108,288 KB
testcase_11 AC 856 ms
116,760 KB
testcase_12 AC 367 ms
109,824 KB
testcase_13 AC 387 ms
109,952 KB
testcase_14 AC 341 ms
111,488 KB
testcase_15 AC 418 ms
113,932 KB
testcase_16 AC 421 ms
108,160 KB
testcase_17 AC 749 ms
116,480 KB
testcase_18 AC 800 ms
116,304 KB
testcase_19 AC 492 ms
113,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,X = map(int,input().split())

G = [[] for _ in range(N)]
for _ in range(M):
    u,v,c,t = map(int,input().split())
    u -= 1
    v -= 1
    G[u].append((v,c + t * X))
    G[v].append((u,c + t * X))

import heapq
q = [(0,0)]

inf = 10 ** 20

dist = [inf] * N
dist[0] = 0
while q:
    d,now = heapq.heappop(q)
    if d > dist[now]:continue
    for v,c in G[now]:
        if dist[v] > d + c:
            dist[v] = d + c
            heapq.heappush(q,(d + c,v))
if dist[-1] == inf:
    print(-1)
else:
    k = dist[-1]
    print((k + X - 1) // X)
0