#P6978. Froggy Ford: Optimizing the Frog's Leap
Froggy Ford: Optimizing the Frog's Leap
Froggy Ford: Optimizing the Frog's Leap
Fiona has designed a new computer game called Froggy Ford in which a player helps a frog cross a river by leaping from the shore to a series of stone fords and finally to the opposite shore. The frog is weak, so its leap distance is limited. Without the option to add any additional stone, the optimal route is determined by the largest gap between consecutive stepping stones (including the shores).
To make the game more challenging, Fiona wants to allow the player to add exactly one new stone anywhere in the river. The goal is to choose a position for this new stone to minimize the maximum leap required along the route. In other words, when the new stone is inserted optimally in one of the intervals between consecutive positions (shore/stone/shore), the value
\( \max\left(\frac{d}{2}, d' \right) \)
should be minimized, where \(d\) is the length of the interval in which the new stone is inserted and \(d'\) is the maximum length among all the other intervals which remain unchanged.
If there are several intervals giving the same minimized maximum leap, output the one with the smallest coordinate for the new stone.
Note: The shores are at positions 0 and \(L\), and the existing stone fords are located strictly between them.
inputFormat
The first line contains two integers \(N\) and \(L\) (\(0 \leq N \leq 10^5\) and \(1 \leq L \leq 10^9\)), where \(N\) is the number of existing stone fords and \(L\) is the width of the river (the position of the far shore).
The second line contains \(N\) distinct integers, each between 1 and \(L-1\), representing the positions of the stone fords. These positions may be given in any order.
outputFormat
Output a single number representing the coordinate where the new stone should be placed to minimize the maximum leap in the optimal route. The result should be printed as a floating‐point number. If the answer is an integer, you may print it with a decimal point (e.g. 5.0).
sample
3 17
2 11 14
6.5