結果

問題 No.2387 Yokan Factory
ユーザー sotanishysotanishy
提出日時 2023-07-21 21:59:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,723 ms / 5,000 ms
コード長 902 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,452 KB
実行使用メモリ 276,848 KB
最終ジャッジ日時 2023-10-21 22:01:30
合計ジャッジ時間 24,128 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,376 KB
testcase_01 AC 39 ms
53,376 KB
testcase_02 AC 36 ms
53,376 KB
testcase_03 AC 36 ms
53,376 KB
testcase_04 AC 36 ms
53,376 KB
testcase_05 AC 36 ms
53,376 KB
testcase_06 AC 36 ms
53,376 KB
testcase_07 AC 38 ms
53,376 KB
testcase_08 AC 36 ms
53,376 KB
testcase_09 AC 36 ms
53,376 KB
testcase_10 AC 37 ms
53,376 KB
testcase_11 AC 38 ms
53,376 KB
testcase_12 AC 36 ms
53,376 KB
testcase_13 AC 36 ms
53,376 KB
testcase_14 AC 36 ms
53,376 KB
testcase_15 AC 1,176 ms
269,120 KB
testcase_16 AC 698 ms
248,544 KB
testcase_17 AC 1,733 ms
276,848 KB
testcase_18 AC 1,647 ms
261,428 KB
testcase_19 AC 1,409 ms
265,988 KB
testcase_20 AC 1,159 ms
239,100 KB
testcase_21 AC 2,430 ms
270,328 KB
testcase_22 AC 1,161 ms
230,128 KB
testcase_23 AC 1,711 ms
268,292 KB
testcase_24 AC 1,025 ms
213,736 KB
testcase_25 AC 1,135 ms
220,628 KB
testcase_26 AC 2,181 ms
273,836 KB
testcase_27 AC 2,723 ms
261,480 KB
testcase_28 AC 103 ms
76,372 KB
testcase_29 AC 132 ms
77,416 KB
testcase_30 AC 117 ms
76,876 KB
testcase_31 AC 124 ms
76,700 KB
testcase_32 AC 97 ms
76,048 KB
testcase_33 AC 86 ms
76,048 KB
testcase_34 AC 121 ms
77,368 KB
testcase_35 AC 111 ms
76,992 KB
testcase_36 AC 85 ms
76,000 KB
testcase_37 AC 40 ms
59,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline


def dijkstra(G, s):
    from heapq import heappush, heappop

    INF = 10**18
    dist = [INF] * len(G)
    dist[s] = 0
    pq = [(0, s)]
    while pq:
        d, v = heappop(pq)
        if d > dist[v]:
            continue
        for u, weight in G[v]:
            nd = d + weight
            if dist[u] > nd:
                dist[u] = nd
                heappush(pq, (nd, u))
    return dist


N, M, X = map(int, input().split())
edges = []
for _ in range(M):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    edges.append((u, v, a, b))
lb, ub = -1, 10**10
while ub - lb > 1:
    m = (lb + ub) // 2
    G = [[]for _ in range(N)]
    for u, v, a, b in edges:
        if b >= m:
            G[u].append((v, a))
            G[v].append((u, a))
    dist = dijkstra(G, 0)
    if dist[N-1] <= X:
        lb = m
    else:
        ub = m
print(lb)
0