結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,560 KB
testcase_01 AC 44 ms
55,560 KB
testcase_02 AC 44 ms
55,560 KB
testcase_03 AC 44 ms
55,560 KB
testcase_04 AC 43 ms
55,560 KB
testcase_05 AC 44 ms
55,560 KB
testcase_06 AC 44 ms
55,560 KB
testcase_07 AC 43 ms
55,560 KB
testcase_08 AC 43 ms
55,560 KB
testcase_09 AC 43 ms
55,560 KB
testcase_10 AC 44 ms
55,560 KB
testcase_11 AC 43 ms
55,560 KB
testcase_12 AC 44 ms
55,560 KB
testcase_13 AC 44 ms
55,560 KB
testcase_14 AC 43 ms
55,560 KB
testcase_15 AC 943 ms
121,508 KB
testcase_16 AC 636 ms
125,136 KB
testcase_17 AC 1,668 ms
181,184 KB
testcase_18 AC 2,394 ms
131,364 KB
testcase_19 AC 1,233 ms
104,732 KB
testcase_20 AC 634 ms
98,312 KB
testcase_21 AC 2,265 ms
129,404 KB
testcase_22 AC 779 ms
98,088 KB
testcase_23 AC 2,303 ms
117,304 KB
testcase_24 AC 734 ms
98,736 KB
testcase_25 AC 859 ms
94,716 KB
testcase_26 AC 1,206 ms
109,348 KB
testcase_27 AC 638 ms
110,532 KB
testcase_28 AC 96 ms
77,092 KB
testcase_29 AC 102 ms
77,196 KB
testcase_30 AC 135 ms
77,888 KB
testcase_31 AC 137 ms
77,336 KB
testcase_32 AC 108 ms
76,524 KB
testcase_33 AC 102 ms
76,652 KB
testcase_34 AC 148 ms
78,144 KB
testcase_35 AC 134 ms
77,912 KB
testcase_36 AC 62 ms
66,388 KB
testcase_37 AC 44 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 + 10
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