結果
問題 | No.2387 Yokan Factory |
ユーザー |
![]() |
提出日時 | 2023-07-22 18:07:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 4,025 ms / 5,000 ms |
コード長 | 902 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 82,852 KB |
実行使用メモリ | 266,060 KB |
最終ジャッジ日時 | 2024-09-22 17:40:00 |
合計ジャッジ時間 | 29,151 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
# coding: utf-8 # Your code here! import heapq as hq def dijkstra(edges,start,size): n_node=len(edges) costs=[float("inf") for i in range(n_node)] queue=[(0,start)] while queue: cost,now=hq.heappop(queue) if costs[now]>cost: costs[now]=cost if now==N-1: break for n_cost,width,nxt in edges[now]: if width>=size: hq.heappush(queue,(cost+n_cost,nxt)) return costs[:] N,M,X=map(int,input().split()) edges=[[] for i in range(N)] for _ in range(M): u,v,a,b=map(int,input().split()) edges[u-1].append((a,b,v-1)) edges[v-1].append((a,b,u-1)) high=10**9+1 low=-1 while high-low>1: middle=(high+low)//2 costs=dijkstra(edges,0,middle) if costs[-1]<=X: low=middle else: high=middle print(low)