Social Distancing
InterviewTime limit1sMemory limit512 MB
Choose s of n outlet positions to maximize the minimum distance between any two chosen seats.
- Level
Medium5 of 10
- Topics
- Binary search, Greedy, Sorting, Array
- Solved
- No attempts yet
Problem
Albert has agreed to help run a Hackathon hosted by University L. Under the social distancing policy, he wants to assign seats so that all participants are as far apart as possible. To do this, he places monitors, desks, and chairs at specific positions along a very long hallway, and each seat can hold at most one team. A total of teams take part in the event, and power outlets are installed along the hallway. A seat can only be placed where an outlet is installed. For convenience, let the positions of the outlets be , where each is the distance from the hallway entrance. That is, the -th outlet is away from the hallway entrance.
Albert wants to choose of the outlet positions for seats so that the distance between the two closest seats, call it , is as large as possible.
For example, let , , and . Here , so a seat must be placed at every outlet position. The distance between the two closest seats is . As another example, let , , and . Placing seats at , , , and makes the distance between the two closest seats 5. Choosing , , , and also works. There is no way to place 4 seats so that the distance between the two closest seats is at least 6.
Given , , and , write a program that prints the largest possible value of .
Input
The first line gives the number of test cases . Each test case spans two lines.
The first line gives and separated by a space. The next line gives integers separated by spaces, the positions of the installed outlets.
Output
For each test case, print the largest achievable value of .
Constraints
- The values are distinct.