結果

問題 No.2387 Yokan Factory
ユーザー cleanttedcleantted
提出日時 2023-06-14 14:49:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 4,607 ms / 5,000 ms
コード長 1,344 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 61,852 KB
最終ジャッジ日時 2023-10-18 00:31:41
合計ジャッジ時間 31,790 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,240 KB
testcase_01 AC 32 ms
10,240 KB
testcase_02 AC 33 ms
10,240 KB
testcase_03 AC 29 ms
10,240 KB
testcase_04 AC 29 ms
10,240 KB
testcase_05 AC 29 ms
10,240 KB
testcase_06 AC 29 ms
10,244 KB
testcase_07 AC 32 ms
10,244 KB
testcase_08 AC 30 ms
10,244 KB
testcase_09 AC 30 ms
10,244 KB
testcase_10 AC 30 ms
10,240 KB
testcase_11 AC 29 ms
10,240 KB
testcase_12 AC 30 ms
10,240 KB
testcase_13 AC 30 ms
10,240 KB
testcase_14 AC 29 ms
10,240 KB
testcase_15 AC 2,479 ms
56,300 KB
testcase_16 AC 1,292 ms
60,680 KB
testcase_17 AC 4,607 ms
61,852 KB
testcase_18 AC 3,795 ms
55,184 KB
testcase_19 AC 1,861 ms
40,972 KB
testcase_20 AC 835 ms
38,068 KB
testcase_21 AC 3,486 ms
51,256 KB
testcase_22 AC 889 ms
35,380 KB
testcase_23 AC 4,229 ms
41,264 KB
testcase_24 AC 1,145 ms
37,280 KB
testcase_25 AC 1,409 ms
28,272 KB
testcase_26 AC 2,156 ms
44,028 KB
testcase_27 AC 1,119 ms
47,744 KB
testcase_28 AC 38 ms
10,880 KB
testcase_29 AC 38 ms
11,116 KB
testcase_30 AC 40 ms
11,064 KB
testcase_31 AC 38 ms
10,704 KB
testcase_32 AC 36 ms
10,524 KB
testcase_33 AC 35 ms
10,484 KB
testcase_34 AC 43 ms
11,068 KB
testcase_35 AC 44 ms
10,896 KB
testcase_36 AC 34 ms
10,464 KB
testcase_37 AC 32 ms
10,248 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 c + a > X:
                    continue

                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