結果

問題 No.2387 Yokan Factory
ユーザー minimumminimum
提出日時 2023-07-21 23:01:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,494 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 81,556 KB
実行使用メモリ 113,324 KB
最終ジャッジ日時 2023-10-21 23:03:58
合計ジャッジ時間 9,388 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,404 KB
testcase_01 AC 37 ms
53,404 KB
testcase_02 AC 36 ms
53,404 KB
testcase_03 AC 36 ms
53,404 KB
testcase_04 AC 39 ms
53,404 KB
testcase_05 AC 36 ms
53,404 KB
testcase_06 AC 35 ms
53,404 KB
testcase_07 AC 37 ms
53,404 KB
testcase_08 AC 36 ms
53,404 KB
testcase_09 WA -
testcase_10 AC 37 ms
53,404 KB
testcase_11 AC 37 ms
53,404 KB
testcase_12 AC 37 ms
53,404 KB
testcase_13 AC 36 ms
53,404 KB
testcase_14 AC 38 ms
53,404 KB
testcase_15 AC 859 ms
108,968 KB
testcase_16 AC 492 ms
113,324 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from heapq import heappop, heappush
input = sys.stdin.readline


def main():
    INF = 10 ** 18
    N, M, X = map(int, input().split())
    edges = [[] for i in range(N)]
    edges_a = [[] for i in range(N)]
    edges_b = [[] for i in range(N)]
    bs = []

    for i in range(M):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        edges[u].append(v)
        edges_a[u].append(a)
        edges_b[u].append(b)
        edges[v].append(u)
        edges_a[v].append(a)
        edges_b[v].append(b)
        bs.append(b)
    bs.sort()

    ok = -1
    ng = N

    while ng - ok > 1:
        md = (ng + ok) // 2
        m = bs[md]
        dist = [INF] * N
        hq = []
        heappush(hq, 0)
        dist[0] = 0
        f = 0
        while hq:
            now = heappop(hq) % (10 ** 9)
            for i in range(len(edges[now])):
                b = edges_b[now][i]
                if b < m:
                    continue
                nxt = edges[now][i]
                a = edges_a[now][i]
                if dist[nxt] <= dist[now] + a:
                    continue
                dist[nxt] = dist[now] + a
                heappush(hq, dist[nxt] * (10 ** 9) + nxt)
                if nxt == N - 1 and dist[-1] <= X:
                    f = 1
                    break
        if f:
            ok = md
        else:
            ng = md
    
    if ok == -1:
        print(-1)
    else:
        print(bs[ok])


if __name__ == '__main__':
    main()
0