結果

問題 No.2387 Yokan Factory
ユーザー cleanttedcleantted
提出日時 2023-06-14 15:26:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,096 ms / 5,000 ms
コード長 1,320 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 87,344 KB
実行使用メモリ 192,056 KB
最終ジャッジ日時 2023-09-06 01:21:16
合計ジャッジ時間 20,316 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,196 KB
testcase_01 AC 75 ms
70,992 KB
testcase_02 AC 76 ms
71,036 KB
testcase_03 AC 77 ms
71,184 KB
testcase_04 AC 75 ms
71,032 KB
testcase_05 AC 76 ms
70,764 KB
testcase_06 AC 77 ms
71,112 KB
testcase_07 AC 75 ms
71,216 KB
testcase_08 AC 76 ms
71,076 KB
testcase_09 AC 76 ms
71,056 KB
testcase_10 AC 76 ms
71,224 KB
testcase_11 AC 75 ms
71,132 KB
testcase_12 AC 74 ms
71,040 KB
testcase_13 AC 78 ms
71,068 KB
testcase_14 AC 75 ms
71,036 KB
testcase_15 AC 970 ms
131,632 KB
testcase_16 AC 517 ms
127,432 KB
testcase_17 AC 1,447 ms
192,056 KB
testcase_18 AC 2,096 ms
142,320 KB
testcase_19 AC 1,019 ms
115,228 KB
testcase_20 AC 554 ms
103,608 KB
testcase_21 AC 1,965 ms
146,104 KB
testcase_22 AC 594 ms
102,748 KB
testcase_23 AC 2,067 ms
132,112 KB
testcase_24 AC 688 ms
105,532 KB
testcase_25 AC 858 ms
102,712 KB
testcase_26 AC 1,189 ms
126,776 KB
testcase_27 AC 674 ms
119,480 KB
testcase_28 AC 127 ms
78,436 KB
testcase_29 AC 123 ms
77,712 KB
testcase_30 AC 149 ms
78,432 KB
testcase_31 AC 139 ms
77,964 KB
testcase_32 AC 122 ms
77,380 KB
testcase_33 AC 124 ms
77,384 KB
testcase_34 AC 154 ms
78,440 KB
testcase_35 AC 171 ms
78,788 KB
testcase_36 AC 89 ms
75,288 KB
testcase_37 AC 76 ms
71,072 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((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
            
            if fixed[i]:
                continue
            fixed[i] = True

            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