結果

問題 No.2387 Yokan Factory
ユーザー i_takui_taku
提出日時 2023-07-21 21:50:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,031 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,748 KB
実行使用メモリ 204,188 KB
最終ジャッジ日時 2023-10-21 21:50:05
合計ジャッジ時間 30,092 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,496 KB
testcase_01 AC 49 ms
55,496 KB
testcase_02 AC 46 ms
55,496 KB
testcase_03 AC 45 ms
55,496 KB
testcase_04 AC 44 ms
55,496 KB
testcase_05 AC 45 ms
55,496 KB
testcase_06 AC 44 ms
55,496 KB
testcase_07 AC 44 ms
55,496 KB
testcase_08 AC 44 ms
55,496 KB
testcase_09 AC 44 ms
55,496 KB
testcase_10 AC 44 ms
55,496 KB
testcase_11 AC 44 ms
55,496 KB
testcase_12 AC 43 ms
55,496 KB
testcase_13 AC 44 ms
55,496 KB
testcase_14 AC 44 ms
55,496 KB
testcase_15 AC 1,293 ms
155,212 KB
testcase_16 AC 679 ms
160,756 KB
testcase_17 WA -
testcase_18 AC 1,690 ms
154,672 KB
testcase_19 AC 2,419 ms
138,184 KB
testcase_20 AC 1,895 ms
132,308 KB
testcase_21 AC 3,401 ms
146,712 KB
testcase_22 AC 1,794 ms
122,188 KB
testcase_23 AC 2,649 ms
146,640 KB
testcase_24 AC 941 ms
112,304 KB
testcase_25 AC 1,613 ms
121,828 KB
testcase_26 AC 2,855 ms
143,708 KB
testcase_27 AC 3,488 ms
180,248 KB
testcase_28 AC 110 ms
77,264 KB
testcase_29 WA -
testcase_30 AC 127 ms
78,068 KB
testcase_31 WA -
testcase_32 AC 91 ms
76,272 KB
testcase_33 AC 99 ms
76,484 KB
testcase_34 WA -
testcase_35 AC 122 ms
77,380 KB
testcase_36 AC 97 ms
76,464 KB
testcase_37 AC 44 ms
55,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline()[:-1]
from heapq import heappush, heappop
from collections import defaultdict

N, M, X = map(int, input().split())
INF = float('inf')
g = [defaultdict(list) for _ in range(N)]

def main():
    for _ in range(M):
        u, v, a, b = map(int, input().split())
        u -= 1; v -= 1
        g[u][v].append((a, b))
        g[v][u].append((a, b))

    ok = 0
    ng = 1 << 60
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if dijkstra(mid):
            ok = mid
        else:
            ng = mid
    print(ok if 0 < ok <= X else -1)
    
def dijkstra(s):
    hq = [(0, 0)]
    dist = [INF] * N
    dist[0] = 0
    while hq:
        d, u = heappop(hq)
        if dist[u] < d:
            continue
        for v in g[u]:
            for a, b in g[u][v]:
                if b < s:
                    continue
                if dist[u] + a < dist[v]:
                    dist[v] = dist[u] + a
                    heappush(hq, (dist[v], v))
    return dist[N - 1] <= X

main()
0