結果

問題 No.2387 Yokan Factory
ユーザー titiatitia
提出日時 2023-07-22 00:25:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,321 ms / 5,000 ms
コード長 817 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 81,476 KB
実行使用メモリ 208,064 KB
最終ジャッジ日時 2023-10-22 00:19:04
合計ジャッジ時間 22,994 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,336 KB
testcase_01 AC 40 ms
53,336 KB
testcase_02 AC 38 ms
53,336 KB
testcase_03 AC 40 ms
53,336 KB
testcase_04 AC 39 ms
53,336 KB
testcase_05 AC 39 ms
53,336 KB
testcase_06 AC 40 ms
53,336 KB
testcase_07 AC 40 ms
53,336 KB
testcase_08 AC 40 ms
53,336 KB
testcase_09 AC 40 ms
53,336 KB
testcase_10 AC 40 ms
53,336 KB
testcase_11 AC 40 ms
53,336 KB
testcase_12 AC 40 ms
53,336 KB
testcase_13 AC 39 ms
53,336 KB
testcase_14 AC 39 ms
53,336 KB
testcase_15 AC 1,388 ms
148,524 KB
testcase_16 AC 729 ms
133,868 KB
testcase_17 AC 1,956 ms
208,064 KB
testcase_18 AC 1,584 ms
127,932 KB
testcase_19 AC 2,238 ms
129,400 KB
testcase_20 AC 1,859 ms
119,468 KB
testcase_21 AC 3,321 ms
156,272 KB
testcase_22 AC 1,629 ms
115,164 KB
testcase_23 AC 2,455 ms
135,792 KB
testcase_24 AC 1,075 ms
108,000 KB
testcase_25 AC 201 ms
86,984 KB
testcase_26 AC 306 ms
96,836 KB
testcase_27 AC 346 ms
100,264 KB
testcase_28 AC 120 ms
76,752 KB
testcase_29 AC 155 ms
77,376 KB
testcase_30 AC 144 ms
77,464 KB
testcase_31 AC 136 ms
77,076 KB
testcase_32 AC 102 ms
76,060 KB
testcase_33 AC 92 ms
75,964 KB
testcase_34 AC 163 ms
77,640 KB
testcase_35 AC 75 ms
73,364 KB
testcase_36 AC 97 ms
76,012 KB
testcase_37 AC 41 ms
53,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from heapq import heappop,heappush

N,M,X=map(int,input().split())

E=[[] for i in range(N+1)]

for i in range(M):
    u,v,a,b=map(int,input().split())
    E[u].append((v,a,b))
    E[v].append((u,a,b))

def calc(NG):

    DIS=[1<<63]*(N+1)
    DIS[1]=0
    Q=[(0,1)]

    while Q:
        now,ind=heappop(Q)

        if DIS[ind]!=now:
            continue

        for to,dis,b in E[ind]:
            if b<NG:
                continue

            if DIS[to]>now+dis:
                DIS[to]=now+dis
                heappush(Q,(DIS[to],to))

    return DIS[N]

if calc(0)>X:
    print(-1)
else:
    OK=0
    NG=10**18+1

    while NG>OK+1:
        mid=(OK+NG)//2

        x=calc(mid)

        if x>X:
            NG=mid
        else:
            OK=mid

    print(OK)

        
0