結果

問題 No.2387 Yokan Factory
ユーザー cleanttedcleantted
提出日時 2023-06-15 22:48:20
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,241 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 86,744 KB
実行使用メモリ 141,884 KB
最終ジャッジ日時 2023-09-06 01:20:48
合計ジャッジ時間 10,459 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
71,268 KB
testcase_01 AC 84 ms
71,340 KB
testcase_02 AC 84 ms
71,296 KB
testcase_03 AC 83 ms
71,040 KB
testcase_04 AC 80 ms
71,276 KB
testcase_05 AC 82 ms
71,112 KB
testcase_06 AC 82 ms
71,008 KB
testcase_07 AC 84 ms
71,016 KB
testcase_08 AC 83 ms
71,000 KB
testcase_09 AC 83 ms
70,908 KB
testcase_10 AC 84 ms
71,152 KB
testcase_11 AC 82 ms
70,928 KB
testcase_12 AC 80 ms
71,108 KB
testcase_13 AC 82 ms
71,272 KB
testcase_14 AC 81 ms
71,000 KB
testcase_15 AC 1,001 ms
131,916 KB
testcase_16 AC 518 ms
127,900 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

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((v, a, b))
        G[v].append((u, a, b))

    def f(m):
        S = [(0, 0)]
        fixed = [False] * N
        D = [X + 1] * N
        D[0] = 0
        while S:
            c, i = heapq.heappop(S)
            if i == N - 1:
                return c <= X
           

            for j, a, b in G[i]:
                if m > b:
                    continue
                
                c2 = c + a
                if c2 > X:
                    continue

                if D[j] <= c2:
                    continue
                D[j] = c2
                heapq.heappush(S, (c2, j))
        
        return False

    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