Fish Catch
Time limit1sMemory limit128 MB
Given a fixed net center and N fish moving at constant velocity, find the smallest radius that catches at least K fish at some time t >= 0.
- Level
Hard8 of 10
- Topics
- Geometry, Binary search, Intervals
- Solved
- No attempts yet
Problem
Fishermen off the coast catch a very lazy kind of fish that swims along a straight line at a constant speed, almost never changing its direction or velocity. Each fisherman uses a circular net whose radius can be adjusted freely, and has already fixed the center of the net at a single point.
There are fish. For each fish you are given its position at time and its position one second later; the fish keeps moving along the straight line through those two points at the same constant speed. The fishermen may lower the net at any single moment , and a fish is caught if at that moment it lies inside or on the boundary of the net.
They want to catch at least fish in one dip, but they do not want to catch more than necessary so that enough fish remain in the ocean, so they want the net as small as possible. Find the smallest radius such that there exists a moment at which at least fish lie within distance of the center.
Input
The first line contains two integers and (), the coordinates of the center of the net.
The second line contains two integers and (, ).
Each of the next lines contains four integers , , , (): is the position of a fish at time , and is its position at time . Each fish moves along a straight line at constant speed, so at time it is located at .
Output
Print a single real number , the required radius of the net, rounded to exactly digits after the decimal point, followed by a newline.