結果

問題 No.2387 Yokan Factory
ユーザー cleanttedcleantted
提出日時 2023-06-14 14:08:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,743 ms / 5,000 ms
コード長 1,284 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 216,404 KB
最終ジャッジ日時 2023-09-06 01:07:24
合計ジャッジ時間 25,521 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,812 KB
testcase_01 AC 75 ms
71,228 KB
testcase_02 AC 76 ms
71,152 KB
testcase_03 AC 76 ms
71,252 KB
testcase_04 AC 76 ms
71,228 KB
testcase_05 AC 75 ms
71,236 KB
testcase_06 AC 75 ms
71,028 KB
testcase_07 AC 76 ms
71,040 KB
testcase_08 AC 75 ms
71,068 KB
testcase_09 AC 75 ms
71,204 KB
testcase_10 AC 76 ms
71,252 KB
testcase_11 AC 76 ms
71,268 KB
testcase_12 AC 74 ms
70,712 KB
testcase_13 AC 73 ms
71,424 KB
testcase_14 AC 76 ms
71,228 KB
testcase_15 AC 1,317 ms
158,916 KB
testcase_16 AC 670 ms
133,212 KB
testcase_17 AC 1,883 ms
216,404 KB
testcase_18 AC 2,317 ms
161,108 KB
testcase_19 AC 1,534 ms
134,924 KB
testcase_20 AC 942 ms
118,812 KB
testcase_21 AC 2,424 ms
169,840 KB
testcase_22 AC 951 ms
112,396 KB
testcase_23 AC 2,454 ms
148,292 KB
testcase_24 AC 847 ms
111,560 KB
testcase_25 AC 1,148 ms
119,760 KB
testcase_26 AC 2,743 ms
160,824 KB
testcase_27 AC 1,097 ms
145,220 KB
testcase_28 AC 130 ms
78,424 KB
testcase_29 AC 158 ms
78,988 KB
testcase_30 AC 151 ms
78,728 KB
testcase_31 AC 148 ms
78,480 KB
testcase_32 AC 116 ms
78,056 KB
testcase_33 AC 118 ms
77,624 KB
testcase_34 AC 175 ms
78,692 KB
testcase_35 AC 157 ms
78,728 KB
testcase_36 AC 102 ms
76,332 KB
testcase_37 AC 76 ms
71,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

def read_values(): return tuple(map(int, input().split()))
def read_index(): return tuple(map(lambda x: int(x) - 1, input().split()))
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for _ in range(N)]


def main():
    N, M, X = read_values() 
    L = read_lists(M)

    G = [[] for _ in range(N)]

    for u, v, a, b in L:
        u -= 1
        v -= 1
        G[u].append((b, v, a))
        G[v].append((b, u, a))
    for i in range(N):
        G[i].sort(reverse=True)

    def f(m):
        S = [(0, 0)]
        fixed = [False] * N
        D = [10 ** 20] * N
        D[0] = 0
        while S:
            c, i = heapq.heappop(S)
            if i == N - 1:
                break
            
            if fixed[i]:
                continue
            fixed[i] = True

            for b, j, a in G[i]:
                if m > b:
                    break

                if D[j] <= c + a:
                    continue
                D[j] = c + a
                heapq.heappush(S, (c + a, j))
        
        return D[N - 1] <= X

    l = -1
    r = 10 ** 9 + 10
    while r - l > 1:
        m = (l + r) // 2
        if f(m):
            l = m
        else:
            r = m

    print(l)


if __name__ == "__main__":
    main()
0