結果

問題 No.2387 Yokan Factory
ユーザー 👑 MizarMizar
提出日時 2023-07-20 02:42:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,188 ms / 5,000 ms
コード長 745 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,600 KB
実行使用メモリ 183,516 KB
最終ジャッジ日時 2023-10-20 04:51:42
合計ジャッジ時間 19,883 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,488 KB
testcase_01 AC 40 ms
53,488 KB
testcase_02 AC 43 ms
53,488 KB
testcase_03 AC 40 ms
53,488 KB
testcase_04 AC 41 ms
53,488 KB
testcase_05 AC 41 ms
53,488 KB
testcase_06 AC 40 ms
53,488 KB
testcase_07 AC 41 ms
53,488 KB
testcase_08 AC 40 ms
53,488 KB
testcase_09 AC 41 ms
53,488 KB
testcase_10 AC 40 ms
53,488 KB
testcase_11 AC 42 ms
53,488 KB
testcase_12 AC 42 ms
53,488 KB
testcase_13 AC 41 ms
53,488 KB
testcase_14 AC 41 ms
53,488 KB
testcase_15 AC 933 ms
124,424 KB
testcase_16 AC 487 ms
120,068 KB
testcase_17 AC 1,374 ms
183,516 KB
testcase_18 AC 2,142 ms
137,252 KB
testcase_19 AC 1,116 ms
109,468 KB
testcase_20 AC 580 ms
99,380 KB
testcase_21 AC 2,077 ms
140,572 KB
testcase_22 AC 590 ms
98,388 KB
testcase_23 AC 2,188 ms
125,060 KB
testcase_24 AC 761 ms
100,112 KB
testcase_25 AC 826 ms
98,816 KB
testcase_26 AC 1,144 ms
115,748 KB
testcase_27 AC 654 ms
112,256 KB
testcase_28 AC 87 ms
76,456 KB
testcase_29 AC 82 ms
74,120 KB
testcase_30 AC 124 ms
77,460 KB
testcase_31 AC 123 ms
76,152 KB
testcase_32 AC 88 ms
75,736 KB
testcase_33 AC 91 ms
75,880 KB
testcase_34 AC 136 ms
77,448 KB
testcase_35 AC 130 ms
77,524 KB
testcase_36 AC 50 ms
57,588 KB
testcase_37 AC 40 ms
53,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def d(m):
    H = [(0, 1)]
    F = [False] * (N + 1)
    D = [X + 1] * (N + 1)
    D[1] = 0
    while H:
        t, i = heapq.heappop(H)
        if i == N:
            return t <= X
        if F[i]:
            continue
        F[i] = True
        for j, a, b in G[i]:
            t2 = t + a
            if m > b or t2 > X or D[j] <= t2:
                continue
            D[j] = t2
            heapq.heappush(H, (t2, j))
    return False

l, r = -1, 10 ** 9 + 1
while r - l > 1:
    m = (l + r) // 2
    l, r = (m, r) if d(m) else (l, m)
print(l)
0