Standing Long Jump
InterviewTime limit1sMemory limit128 MB
Remove exactly m of n interior stones so the smallest gap between consecutive stepping points from 0 to d is as large as possible.
- Level
Medium6 of 10
- Topics
- Binary search, Greedy, Array, Sorting
- Solved
- No attempts yet
Problem
Students train for the standing long jump. The training ground is filled with boiling lava, so a student must cross to the exit on the far side by stepping on stone islands placed over the lava.
The student starts on the island at position , and the exit is at position . Between the start island and the exit there are small stone islands; the position of each island is given as its distance from the start island.
The teacher removes exactly of these small islands. The student then steps on every one of the remaining small islands, jumping in order of position from the start island to the exit. (No matter how far apart two islands are, the jump always succeeds — the student never falls into the lava.)
The length of a single jump is the distance between two consecutive stepping points. That is, lay out the start island, the remaining small islands, and the exit in order of position; the distances between adjacent points are the jump lengths.
Choose which islands to remove so as to maximize the minimum jump length. Output that maximum possible value.
Input
The first line contains the distance from the start island to the exit (), the number of small islands (), and the number of islands to remove (), separated by spaces.
Each of the next lines contains one integer: the position of a small island (its distance from the start island). All island positions are distinct.
Output
Print the maximum achievable value of the minimum jump length after removing islands.