Fireflies
Time limit1sMemory limit128 MB
Choose a shutter time that minimizes the side length of an axis-aligned square holding all fireflies moving at constant velocities.
- Level
Medium6 of 10
- Topics
- Binary search, Geometry
- Solved
- No attempts yet
Problem
There are fireflies moving in a plane. Firefly starts at and moves with constant velocity . After time its position is .
You want to capture every firefly in one axis-aligned square photo frame. You may choose the shutter time freely. Find the minimum side length of a square, with sides parallel to the axes, that can contain all fireflies at some time .
Input
The first line contains an integer ().
Each of the next lines contains four integers (). is the starting position and is the velocity vector.
Output
Print one real number , the minimum possible side length of an axis-aligned square that covers all fireflies at some time . Your answer is accepted if it differs from the correct value by at most in absolute or relative error.
Hint
At any time, compute the span of coordinates and the span of coordinates; the needed side length is the larger of the two. The objective over time is convex, so ternary search works.