#P1783. Sealing the Invasion
Sealing the Invasion
Sealing the Invasion
WLP has been troubled by the enemy raids on his shipyard and warehouse near the beach while he enjoys his online battle game. In order to monitor the entire beach, he divides the beach into several vertical columns (perpendicular to the coastline) and places a few signal towers in some of these columns. Each signal tower has a working radius, meaning that any enemy within a circular area of radius \(r\) centered at the tower will be detected.
However, the enemies are very cunning. They can take any arbitrarily curved path inside the region bounded by the two vertical boundaries constructed by the 0-th and \(N\)-th columns in order to sneak through, as long as the path does not cross these boundaries. In order to prevent any enemy from infiltrating from the beach to the inland, WLP wonders:
What is the minimum radius \(r\) required for each signal tower such that every continuous path from the beach to the inland will intersect at least one tower's circular surveillance area?
Note that if the union of the signal towers' circles completely covers the interval \([0, N]\) along the line on which the towers are placed, then any continuous curve (by the intermediate value theorem) crossing from one side to the other must pass through a tower's circular area. With the towers positioned on some of the columns at positions \(a_1, a_2, \dots, a_M\) (with \(0 < a_1 < a_2 < \cdots < a_M < N\)), the problem reduces to finding the smallest \(r\) such that the union of intervals \([a_i - r, a_i + r]\) covers the entire interval \([0, N]\).
This is equivalent to computing:
\[ r = \max\left(a_1-0,\; N - a_M,\; \max_{1\le i< M} \frac{a_{i+1}-a_i}{2}\right). \]Please output \(r\) as a floating point number with one digit after the decimal point. It is guaranteed that a solution exists.
inputFormat
The input consists of two lines.
The first line contains two integers \(N\) and \(M\) (with \(N > 0\) and \(M \ge 1\)), where \(N\) represents the width of the beach (i.e. the distance between column 0 and column \(N\)), and \(M\) is the number of signal towers.
The second line contains \(M\) integers \(a_1, a_2, \dots, a_M\) (\(0 < a_1 < a_2 < \cdots < a_M < N\)), representing the column indices where the towers are placed.
outputFormat
Output the minimum required radius \(r\) needed for the towers so that any continuous path connecting the two boundaries is intercepted by at least one tower's circular zone. The answer should be printed as a floating point number with one digit after the decimal point.
sample
10 2
2 6
4.0