結果

問題 No.2387 Yokan Factory
ユーザー 👑 rin204rin204
提出日時 2024-04-07 15:01:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,023 ms / 5,000 ms
コード長 871 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 127,580 KB
最終ジャッジ日時 2024-04-07 15:01:21
合計ジャッジ時間 13,244 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 35 ms
53,460 KB
testcase_09 AC 35 ms
53,460 KB
testcase_10 AC 35 ms
53,460 KB
testcase_11 AC 35 ms
53,460 KB
testcase_12 AC 35 ms
53,460 KB
testcase_13 AC 34 ms
53,460 KB
testcase_14 AC 35 ms
53,460 KB
testcase_15 AC 806 ms
116,632 KB
testcase_16 AC 587 ms
121,712 KB
testcase_17 AC 926 ms
127,580 KB
testcase_18 AC 1,023 ms
116,728 KB
testcase_19 AC 547 ms
105,024 KB
testcase_20 AC 380 ms
102,280 KB
testcase_21 AC 989 ms
114,420 KB
testcase_22 AC 392 ms
99,696 KB
testcase_23 AC 936 ms
104,480 KB
testcase_24 AC 428 ms
101,984 KB
testcase_25 AC 352 ms
91,852 KB
testcase_26 AC 513 ms
109,288 KB
testcase_27 AC 400 ms
112,676 KB
testcase_28 AC 83 ms
76,828 KB
testcase_29 AC 70 ms
72,848 KB
testcase_30 AC 98 ms
76,812 KB
testcase_31 AC 104 ms
76,164 KB
testcase_32 AC 73 ms
72,484 KB
testcase_33 AC 71 ms
72,492 KB
testcase_34 AC 119 ms
77,196 KB
testcase_35 AC 104 ms
76,692 KB
testcase_36 AC 49 ms
57,648 KB
testcase_37 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush

n, m, T = map(int, input().split())

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


def ok(x):
    dist = [T + 1] * n
    dist[0] = 0
    hq = [0]
    while hq:
        tmp = heappop(hq)
        d = tmp // n
        pos = tmp - d * n
        if dist[pos] < d:
            continue
        for npos, a, b in edges[pos]:
            if b < x:
                continue
            nd = d + a
            if nd < dist[npos]:
                dist[npos] = nd
                heappush(hq, nd * n + npos)
    return dist[n - 1] <= T


B = sorted(set(B))
l = 0
r = len(B)
while r - l > 1:
    mid = (l + r) // 2
    if ok(B[mid]):
        l = mid
    else:
        r = mid

print(B[l])
0