結果

問題 No.2387 Yokan Factory
ユーザー mono_0812mono_0812
提出日時 2023-07-21 21:51:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,429 ms / 5,000 ms
コード長 2,340 bytes
コンパイル時間 1,074 ms
コンパイル使用メモリ 81,632 KB
実行使用メモリ 220,024 KB
最終ジャッジ日時 2023-10-21 21:53:00
合計ジャッジ時間 25,195 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
91,036 KB
testcase_01 AC 129 ms
91,036 KB
testcase_02 AC 128 ms
91,044 KB
testcase_03 AC 128 ms
91,028 KB
testcase_04 AC 128 ms
91,040 KB
testcase_05 AC 126 ms
91,044 KB
testcase_06 AC 135 ms
91,032 KB
testcase_07 AC 136 ms
91,044 KB
testcase_08 AC 135 ms
91,028 KB
testcase_09 AC 132 ms
91,036 KB
testcase_10 AC 131 ms
91,040 KB
testcase_11 AC 132 ms
91,036 KB
testcase_12 AC 131 ms
91,032 KB
testcase_13 AC 135 ms
91,032 KB
testcase_14 AC 126 ms
91,040 KB
testcase_15 AC 1,151 ms
164,108 KB
testcase_16 AC 632 ms
147,132 KB
testcase_17 AC 1,495 ms
220,024 KB
testcase_18 AC 1,525 ms
156,620 KB
testcase_19 AC 1,588 ms
146,696 KB
testcase_20 AC 1,335 ms
140,220 KB
testcase_21 AC 2,332 ms
181,856 KB
testcase_22 AC 1,241 ms
136,680 KB
testcase_23 AC 1,710 ms
154,152 KB
testcase_24 AC 848 ms
123,208 KB
testcase_25 AC 1,028 ms
130,080 KB
testcase_26 AC 2,130 ms
168,160 KB
testcase_27 AC 2,429 ms
185,196 KB
testcase_28 AC 204 ms
92,516 KB
testcase_29 AC 249 ms
93,172 KB
testcase_30 AC 207 ms
92,528 KB
testcase_31 AC 197 ms
92,092 KB
testcase_32 AC 179 ms
92,080 KB
testcase_33 AC 177 ms
92,076 KB
testcase_34 AC 229 ms
93,068 KB
testcase_35 AC 203 ms
92,508 KB
testcase_36 AC 170 ms
92,052 KB
testcase_37 AC 128 ms
91,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

############################################################################################
import bisect,collections,copy,heapq,itertools,math,string,sys,queue,time,random
from decimal import Decimal
def I(): return input()
def IS(): return input().split()
def II(): return int(input())
def IIS(): return list(map(int,input().split()))
def LIIS(): return list(map(int,input().split()))

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

import math

def prime_numbers(n):
    prime = [True for i in range(n+1)]
    prime[0] = False
    prime[1] = False

    sqrt_n = math.ceil(math.sqrt(n))
    for i in range(2, sqrt_n):
        if prime[i]:
            for j in range(2*i, n+1, i):
                prime[j] = False
    numbers=[]
    for i in range(2,n+1):
        if prime[i]:
            numbers.append(i)

    return numbers

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
INF=1<<63
MOD=998244353
MOD2=10**9+7
sys.setrecursionlimit(500005)
alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def bit_count(x):
    return bin(x).count("1")
def yesno(f):
    if f:print("Yes")
    else:print("No")
####################################################
l=-1
r=10**10
n,m,x=IIS()
path=[[] for i in range(n)]
for _ in range(m):
    u,v,a,b=IIS()
    path[u-1].append((v-1,a,b))
    path[v-1].append((u-1,a,b))

def is_ok(val):
    q=[(0,0)]
    costs=[INF for i in range(n)]
    used=[0 for i in range(n)]
    costs[0]=0
    while q:
        c,v=heapq.heappop(q)
        if used[v]:continue
        used[v]=1
        for i,j,k in path[v]:
            if used[i] or val>k:continue
            if costs[i]>c+j:
                heapq.heappush(q,(c+j,i))
                costs[i]=c+j
    return costs[n-1]<=x

while r-l>1:
    mid=(r+l)//2
    if is_ok(mid):
        l=mid
    else:
        r=mid
print(l)
0