結果

問題 No.2387 Yokan Factory
ユーザー cleanttedcleantted
提出日時 2023-06-15 22:49:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,109 ms / 5,000 ms
コード長 1,320 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 191,460 KB
最終ジャッジ日時 2023-09-06 01:20:28
合計ジャッジ時間 19,411 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,108 KB
testcase_01 AC 77 ms
70,844 KB
testcase_02 AC 77 ms
71,048 KB
testcase_03 AC 79 ms
70,804 KB
testcase_04 AC 76 ms
70,968 KB
testcase_05 AC 78 ms
70,972 KB
testcase_06 AC 77 ms
71,044 KB
testcase_07 AC 75 ms
70,780 KB
testcase_08 AC 75 ms
70,892 KB
testcase_09 AC 78 ms
71,172 KB
testcase_10 AC 77 ms
70,896 KB
testcase_11 AC 76 ms
70,796 KB
testcase_12 AC 77 ms
70,784 KB
testcase_13 AC 77 ms
70,972 KB
testcase_14 AC 74 ms
70,768 KB
testcase_15 AC 954 ms
131,824 KB
testcase_16 AC 509 ms
127,868 KB
testcase_17 AC 1,442 ms
191,460 KB
testcase_18 AC 2,066 ms
142,312 KB
testcase_19 AC 1,078 ms
115,180 KB
testcase_20 AC 581 ms
103,696 KB
testcase_21 AC 1,937 ms
146,132 KB
testcase_22 AC 599 ms
102,792 KB
testcase_23 AC 2,109 ms
132,312 KB
testcase_24 AC 682 ms
105,368 KB
testcase_25 AC 868 ms
102,604 KB
testcase_26 AC 1,184 ms
126,676 KB
testcase_27 AC 657 ms
119,120 KB
testcase_28 AC 124 ms
78,456 KB
testcase_29 AC 120 ms
77,464 KB
testcase_30 AC 146 ms
78,400 KB
testcase_31 AC 140 ms
77,728 KB
testcase_32 AC 120 ms
77,508 KB
testcase_33 AC 124 ms
77,636 KB
testcase_34 AC 153 ms
78,576 KB
testcase_35 AC 162 ms
78,436 KB
testcase_36 AC 87 ms
75,312 KB
testcase_37 AC 78 ms
70,628 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