結果

問題 No.2387 Yokan Factory
ユーザー tassei903tassei903
提出日時 2023-07-21 21:39:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,404 ms / 5,000 ms
コード長 1,057 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 176,452 KB
最終ジャッジ日時 2023-10-21 21:35:20
合計ジャッジ時間 20,686 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,476 KB
testcase_01 AC 37 ms
53,476 KB
testcase_02 AC 35 ms
53,476 KB
testcase_03 AC 35 ms
53,476 KB
testcase_04 AC 34 ms
53,476 KB
testcase_05 AC 34 ms
53,476 KB
testcase_06 AC 34 ms
53,476 KB
testcase_07 AC 34 ms
53,476 KB
testcase_08 AC 34 ms
53,476 KB
testcase_09 AC 34 ms
53,476 KB
testcase_10 AC 33 ms
53,476 KB
testcase_11 AC 36 ms
53,476 KB
testcase_12 AC 34 ms
53,476 KB
testcase_13 AC 34 ms
53,476 KB
testcase_14 AC 33 ms
53,476 KB
testcase_15 AC 936 ms
125,888 KB
testcase_16 AC 482 ms
124,156 KB
testcase_17 AC 1,301 ms
176,452 KB
testcase_18 AC 1,655 ms
125,880 KB
testcase_19 AC 1,522 ms
113,528 KB
testcase_20 AC 1,164 ms
105,104 KB
testcase_21 AC 2,404 ms
132,480 KB
testcase_22 AC 1,061 ms
103,128 KB
testcase_23 AC 1,600 ms
116,020 KB
testcase_24 AC 634 ms
100,328 KB
testcase_25 AC 1,012 ms
99,232 KB
testcase_26 AC 1,910 ms
127,360 KB
testcase_27 AC 2,086 ms
131,780 KB
testcase_28 AC 95 ms
76,680 KB
testcase_29 AC 122 ms
77,784 KB
testcase_30 AC 109 ms
77,420 KB
testcase_31 AC 113 ms
76,852 KB
testcase_32 AC 88 ms
76,176 KB
testcase_33 AC 77 ms
75,904 KB
testcase_34 AC 117 ms
77,492 KB
testcase_35 AC 99 ms
76,684 KB
testcase_36 AC 69 ms
73,788 KB
testcase_37 AC 35 ms
53,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
from heapq import *
INF = 10**18
def dijkstra(g, s, n, x):
    dist = [INF]*n
    hq = [(0, s)]
    dist[s] = 0
    while hq:
        d, v = heappop(hq)
        if dist[v]!=d:
            continue
        for to, a,b, in g[v]:
            if b >= x and dist[v] + a < dist[to]:
                dist[to] = dist[v] + a
                heappush(hq, (dist[to], to))
    return dist
n,m,x = na()

g = [[] for i in range(n)]

for _ in range(m):
    u,v,a,b = na()
    u-=1
    v-=1
    g[u].append((v,a,b))
    g[v].append((u,a,b))

ok = -1
ng = 10**9
while abs(ok-ng)>1:
    d = ok+ng>>1
    dist = dijkstra(g,0,n,d)
    #print(d,dist)
    if dist[-1] <= x:
        ok = d
    else:
        ng = d


print(ok)
0