#C7368. Lanterns Light Coverage
Lanterns Light Coverage
Lanterns Light Coverage
You are given a straight street of length \(l\), running from position 0 to \(l\). On this street, there are \(n\) lanterns installed at various positions. Each lantern illuminates a segment of the street of radius \(r\) (that is, it lights up the interval \([x-r, x+r]\) where \(x\) is its position).
Your task is to determine the minimum radius \(r\) required such that the entire street from 0 to \(l\) is covered by the light. Note that if the lanterns are not placed at the very edges of the street, you must ensure that the intervals from 0 to the first lantern and from the last lantern to \(l\) are also illuminated.
Hint: After sorting the lantern positions, the minimum required radius \(r\) is the maximum of:
- Half the maximum gap between two consecutive lanterns,
- The distance from 0 to the first lantern, and
- The distance from the last lantern to \(l\).
Express any formulas using LaTeX format.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains two integers \(n\) and \(l\), where \(n\) is the number of lanterns and \(l\) is the length of the street.
- The second line contains \(n\) space-separated integers representing the positions of the lanterns on the street.
Constraints:
- \(1 \leq n \leq 10^5\)
- \(1 \leq l \leq 10^9\)
- Lantern positions are between 0 and \(l\), inclusive.
outputFormat
The output should be written to standard output (stdout) and consist of a single floating-point number: the minimum radius \(r\) required such that the entire street is covered by light. The answer should be precise up to at least 6 decimal places if necessary.
## sample2 5
1 4
1.5