結果

問題 No.2387 Yokan Factory
ユーザー nikoro256
提出日時 2023-07-21 22:05:26
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 880 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,564 KB
実行使用メモリ 266,852 KB
最終ジャッジ日時 2024-09-21 23:37:27
合計ジャッジ時間 46,988 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
def daiku(s,num):
    hq=[]
    heapq.heappush(hq,[0,s])
    high=[-1 for _ in range(N)]
    karidist=[10**18+1 for _ in range(N)]
    while len(hq)!=0:
        h,p=heapq.heappop(hq)
        if high[p]==-1:
            high[p]=h
            for e,c,m in edge[p]:
                if m>=num and karidist[e]>h+c:
                    karidist[e]=h+c
                    heapq.heappush(hq,[h+c,e])
    return high[-1]

def nibun():
    left,right=-1,10**9+1
    while right-left>1:
        mid=(right+left)//2
        dist=daiku(0,mid)
        if dist!=-1 and dist<=X:
            left=mid
        else:
            right=mid
    return left

import sys
input=sys.stdin.readline
N,M,X=map(int,input().split())
edge=[[] for _ in range(N)]
for _ in range(M):
    u,v,a,b=map(int,input().split())
    edge[u-1].append([v-1,a,b])
    edge[v-1].append([u-1,a,b])
print(nibun())
0