結果
| 問題 |
No.2387 Yokan Factory
|
| コンテスト | |
| ユーザー |
komkompi
|
| 提出日時 | 2023-07-22 01:27:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 845 bytes |
| コンパイル時間 | 235 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 200,704 KB |
| 最終ジャッジ日時 | 2024-09-22 02:33:55 |
| 合計ジャッジ時間 | 8,612 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 22 |
ソースコード
# 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
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)
komkompi