結果

問題 No.2387 Yokan Factory
ユーザー miya145592miya145592
提出日時 2023-07-21 23:50:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,983 ms / 5,000 ms
コード長 1,002 bytes
コンパイル時間 1,119 ms
コンパイル使用メモリ 81,104 KB
実行使用メモリ 204,412 KB
最終ジャッジ日時 2023-10-21 23:50:10
合計ジャッジ時間 26,142 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,324 KB
testcase_01 AC 36 ms
53,324 KB
testcase_02 AC 38 ms
53,324 KB
testcase_03 AC 39 ms
53,324 KB
testcase_04 AC 38 ms
53,324 KB
testcase_05 AC 37 ms
53,324 KB
testcase_06 AC 35 ms
53,324 KB
testcase_07 AC 34 ms
53,324 KB
testcase_08 AC 36 ms
53,324 KB
testcase_09 AC 37 ms
53,324 KB
testcase_10 AC 35 ms
53,324 KB
testcase_11 AC 35 ms
53,324 KB
testcase_12 AC 35 ms
53,324 KB
testcase_13 AC 35 ms
53,324 KB
testcase_14 AC 35 ms
53,324 KB
testcase_15 AC 1,127 ms
151,172 KB
testcase_16 AC 584 ms
135,512 KB
testcase_17 AC 1,547 ms
204,412 KB
testcase_18 AC 2,286 ms
156,148 KB
testcase_19 AC 1,918 ms
134,924 KB
testcase_20 AC 1,492 ms
123,872 KB
testcase_21 AC 2,983 ms
168,868 KB
testcase_22 AC 1,460 ms
120,664 KB
testcase_23 AC 2,057 ms
140,792 KB
testcase_24 AC 826 ms
107,812 KB
testcase_25 AC 1,337 ms
116,824 KB
testcase_26 AC 2,454 ms
154,732 KB
testcase_27 AC 2,768 ms
165,392 KB
testcase_28 AC 112 ms
77,468 KB
testcase_29 AC 140 ms
77,456 KB
testcase_30 AC 124 ms
77,516 KB
testcase_31 AC 125 ms
76,768 KB
testcase_32 AC 93 ms
75,920 KB
testcase_33 AC 83 ms
75,648 KB
testcase_34 AC 130 ms
77,688 KB
testcase_35 AC 113 ms
77,332 KB
testcase_36 AC 79 ms
75,912 KB
testcase_37 AC 37 ms
53,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop

INF = 10 ** 19

def dijkstra(s, N, w): # (始点, ノード数)
    dist = [INF for _ in range(N)]
    hq = [(0, s)]
    dist[s] = 0
    seen = [False] * N # ノードが確定済みかどうか
    while hq:
        d, v = heappop(hq) # ノードを pop する
        if seen[v]:
            continue
        seen[v] = True
        for to, cost, width in G[v]: # ノード v に隣接しているノードに対して
            if width<w:
                continue
            if dist[v] + cost < dist[to]:
                dist[to] = dist[v] + cost
                heappush(hq, (dist[to], to))
    return dist

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

l = -1
r = 10**9+1
while r-l>1:
    mid = (l+r)//2
    dist = dijkstra(0, N, mid)
    if dist[-1]<=X:
        l = mid
    else:
        r = mid
print(l)
0