Cat and Mice
Time limit2sMemory limit512 MB
Find the smallest initial speed v so the cat can visit all points in some order, each arrival at or before its deadline, with speed multiplied by m after every meal.
- Level
Hard8 of 10
- Topics
- Binary search, Dynamic programming, Bit manipulation, Geometry
- Solved
- No attempts yet
Problem
A cat lives on the Cartesian plane and her home is at . No mouse lives at that point.
At time , mice stick their heads above the ground at distinct points, and the cat sees every one of them. Mouse stays above ground at its point until time , then ducks underground where the cat cannot reach it.
The cat plans to eat every mouse. At time she leaves with initial speed and runs in a straight line toward one of the mice. She eats it the instant she arrives, then runs in a straight line toward another mouse, and she repeats this until no mouse is left. Eating takes no time.
Every meal slows her down: her speed is multiplied by the constant each time she eats a mouse, so after eating mice she moves at speed .
The cat eats mouse only if she reaches its point at time or earlier. Arriving exactly at time still counts.
The cat picks the order that suits her best. Find the smallest initial speed for which some order lets her eat all mice.
Input
The first line contains an integer (), the number of mice.
Each of the next lines contains three integers , , and (, ), meaning that a mouse sits at and ducks underground at time . No two mice share a point, and no mouse is at .
The last line contains (), a decimal number with one or two digits after the decimal point. It may be written without the leading zero, as in .75.
Output
Print the minimum initial speed, in units of distance per second, that lets the cat eat every mouse. Round it to six digits after the decimal point and print exactly six of them.