結果

問題 No.2387 Yokan Factory
ユーザー flygonflygon
提出日時 2023-07-21 21:37:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,137 ms / 5,000 ms
コード長 1,116 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,568 KB
実行使用メモリ 177,832 KB
最終ジャッジ日時 2023-10-21 21:30:37
合計ジャッジ時間 18,239 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,476 KB
testcase_01 AC 46 ms
55,476 KB
testcase_02 AC 45 ms
55,476 KB
testcase_03 AC 44 ms
55,476 KB
testcase_04 AC 45 ms
55,476 KB
testcase_05 AC 44 ms
55,476 KB
testcase_06 AC 45 ms
55,476 KB
testcase_07 AC 45 ms
55,476 KB
testcase_08 AC 45 ms
55,476 KB
testcase_09 AC 44 ms
55,476 KB
testcase_10 AC 47 ms
55,476 KB
testcase_11 AC 46 ms
55,476 KB
testcase_12 AC 46 ms
55,476 KB
testcase_13 AC 45 ms
55,476 KB
testcase_14 AC 45 ms
55,476 KB
testcase_15 AC 1,009 ms
126,964 KB
testcase_16 AC 431 ms
116,820 KB
testcase_17 AC 1,326 ms
177,832 KB
testcase_18 AC 1,974 ms
125,932 KB
testcase_19 AC 1,068 ms
108,972 KB
testcase_20 AC 588 ms
97,888 KB
testcase_21 AC 2,049 ms
131,156 KB
testcase_22 AC 576 ms
96,596 KB
testcase_23 AC 2,137 ms
116,992 KB
testcase_24 AC 754 ms
99,904 KB
testcase_25 AC 918 ms
100,860 KB
testcase_26 AC 1,270 ms
122,812 KB
testcase_27 AC 687 ms
111,888 KB
testcase_28 AC 75 ms
73,300 KB
testcase_29 AC 74 ms
72,740 KB
testcase_30 AC 112 ms
77,248 KB
testcase_31 AC 128 ms
77,308 KB
testcase_32 AC 90 ms
76,452 KB
testcase_33 AC 92 ms
76,048 KB
testcase_34 AC 124 ms
77,916 KB
testcase_35 AC 129 ms
77,500 KB
testcase_36 AC 48 ms
57,532 KB
testcase_37 AC 44 ms
55,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n,m,x = map(int,input().split())
graph = [[] for i in range(n+1)]
for i in range(m):
    a,b,c,d = map(int,input().split())
    graph[a].append((b,c,d))
    graph[b].append((a,c,d))
#ダイクストラ法
def dijkstra(s,n, W): # sがスタート、nが頂点数
    INF = 10**15
    dist = [INF]*(n+1)
    que = [(0,s)]
    dist[s] = 0
    while que:
        c,crr = heappop(que)
        if c > dist[crr]: continue
        if crr == n: break
        if c > x: break
        for nxt, time, width in graph[crr]:
            if width < W: continue
            if dist[crr] + time < dist[nxt]:
                dist[nxt] = dist[crr] + time
                heappush(que,(dist[nxt],nxt))
    return dist[-1]

l = 0
r = 10**9+1
for i in range(30):
    m = (l+r)//2
    t = dijkstra(1,n,m)
    if t <= x:
        l = m
    else:
        r = m

if dijkstra(1,n,l) <= x:
    print(l)
else:
    print(-1)
0