結果

問題 No.2387 Yokan Factory
ユーザー lloyzlloyz
提出日時 2023-07-21 21:49:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,372 ms / 5,000 ms
コード長 792 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 81,704 KB
実行使用メモリ 181,184 KB
最終ジャッジ日時 2023-10-21 21:48:09
合計ジャッジ時間 19,440 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,560 KB
testcase_01 AC 43 ms
55,560 KB
testcase_02 AC 44 ms
55,560 KB
testcase_03 AC 43 ms
55,560 KB
testcase_04 AC 43 ms
55,560 KB
testcase_05 AC 43 ms
55,560 KB
testcase_06 AC 43 ms
55,560 KB
testcase_07 AC 43 ms
55,560 KB
testcase_08 AC 43 ms
55,560 KB
testcase_09 AC 45 ms
55,560 KB
testcase_10 AC 42 ms
55,560 KB
testcase_11 AC 42 ms
55,560 KB
testcase_12 AC 43 ms
55,560 KB
testcase_13 AC 43 ms
55,560 KB
testcase_14 AC 43 ms
55,560 KB
testcase_15 AC 939 ms
121,520 KB
testcase_16 AC 628 ms
125,136 KB
testcase_17 AC 1,633 ms
181,184 KB
testcase_18 AC 2,372 ms
131,368 KB
testcase_19 AC 1,230 ms
104,784 KB
testcase_20 AC 620 ms
98,296 KB
testcase_21 AC 2,242 ms
129,552 KB
testcase_22 AC 775 ms
98,084 KB
testcase_23 AC 2,214 ms
117,304 KB
testcase_24 AC 797 ms
98,896 KB
testcase_25 AC 854 ms
94,692 KB
testcase_26 AC 1,188 ms
109,348 KB
testcase_27 AC 632 ms
110,500 KB
testcase_28 AC 93 ms
77,092 KB
testcase_29 AC 100 ms
77,188 KB
testcase_30 AC 132 ms
77,892 KB
testcase_31 AC 133 ms
77,328 KB
testcase_32 AC 103 ms
76,528 KB
testcase_33 AC 97 ms
76,652 KB
testcase_34 AC 147 ms
77,884 KB
testcase_35 AC 133 ms
77,912 KB
testcase_36 AC 62 ms
66,428 KB
testcase_37 AC 43 ms
55,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from heapq import heappop, heappush

n, m, x = map(int, input().split())
G = defaultdict(list)
for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, a, b))
    G[v].append((u, a, b))

left, right = -1, 10**9
while right - left > 1:
    mid = (left + right) // 2
    DP = [x + 1 for _ in range(n)]
    DP[0] = 0
    H = [(0, 0)]
    while H:
        cc, cp = heappop(H)
        if cc > DP[cp]:
            continue
        for np, a, b in G[cp]:
            if b < mid:
                continue
            if cc + a >= DP[np]:
                continue
            DP[np] = cc + a
            heappush(H, (cc + a, np))
    if DP[n - 1] == x + 1:
        right = mid
    else:
        left = mid
print(left)
0