結果

問題 No.2387 Yokan Factory
ユーザー Akijin_007
提出日時 2023-07-21 21:43:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 553 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 52,992 KB
最終ジャッジ日時 2024-09-21 23:10:25
合計ジャッジ時間 7,854 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 3 TLE * 1 -- * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, X = map(int, input().split())
to = [[] for i in range(N)]
for i in range(M):
    u, v, a, b = map(int, input().split())
    to[u-1].append((v-1, a, b))
    to[v-1].append((u-1, a, b))

import heapq
ans = -1
v = [-1] * N

q = [(-(10**9), 0, 0)]
heapq.heapify(q)

while q:
    s, x, t = heapq.heappop(q)
    if v[x] > -s:
        continue

    for y, a, b in to[x]:
        if t + a > X:
            continue
        if v[y] > min(b, -s):
            continue
        heapq.heappush(q, (-min(b, -s), y, t+a))
        v[y] = min(b, -s)

print(min(v))
0