結果
問題 |
No.2387 Yokan Factory
|
ユーザー |
|
提出日時 | 2023-07-21 23:48:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 686 bytes |
コンパイル時間 | 221 ms |
コンパイル使用メモリ | 82,312 KB |
実行使用メモリ | 173,568 KB |
最終ジャッジ日時 | 2024-09-22 01:14:40 |
合計ジャッジ時間 | 10,079 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 11 WA * 3 TLE * 1 -- * 20 |
ソースコード
import heapq n,m,X=map(int,input().split()) edge=[list(map(int,input().split())) for _ in range(m)] E=[[] for _ in range(n+1)] for u,v,a,b in edge: E[u].append((v,a,b)) E[v].append((u,a,b)) def f(y): D=[10**19]*(n+1) D[1]=0 q=[] heapq.heappush(q,(0,1)) while q: d,x=heapq.heappop(q) for e,a,b in E[x]: if y<=b and D[x]+a<D[e] and D[x]+a<=X: D[e]=D[x]+a heapq.heappush(q,(d+a,e)) if e==n and D[e]<=X:return True # print(y,D) return 0<D[-1]<=X l,r=-1,10**9+2 while l+1<r: m=(l+r)//2 if m<0: exit(print(-1)) flag=f(m) if flag and f(m+1)==0: exit(print(m)) if flag: l=m else: r=m print(m)