Guarding the Border
InterviewTime limit3sMemory limit256 MB
Add up to M towers anywhere on a circular border of length L so the largest gap between neighboring towers is as small as possible.
- Level
Medium5 of 10
- Topics
- Binary search, Greedy, Sorting
- Solved
- No attempts yet
Problem
As the newly appointed chief of security, you have decided to upgrade the border defense. Neighbouring countries are rumoured to be building nuclear weapons, so a few more archer towers are needed. To spot intruders while they are still approaching, you want the largest distance between two adjacent towers to be as small as possible.
The border runs from to and closes on itself, so treat it as a loop of circumference . The country is landlocked, so the first and the last tower are neighbours as well: the coordinates and are the same place. old towers already stand on the border. The budget pays for at most new towers, and you may put each of them anywhere on the border, not only at an integer coordinate. After the placement, find the smallest possible value of the largest distance between two adjacent towers.
If a single tower stands on the loop, it is its own neighbour and the distance between adjacent towers is .
Input
The first line contains the number of test cases . Each of the following lines describes one test case. A line starts with three integers , and . is the number of towers already standing on the border, is the largest number of new towers you may place, and is the length of the border. The positions of the current towers follow on the same line.
- , written with at most 6 digits after the decimal point
- No two towers stand at the same position.
Output
For each test case print one line with the smallest possible value of the largest distance between two adjacent towers, rounded to exactly 6 digits after the decimal point. An answer of is printed as 5.000000. Every answer in the test data is more than away from a point where the rounding direction changes, so double precision arithmetic produces the same output.