CF492B.Vanya and Lanterns
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vanya walks late at night along a straight street of length l, lit by n lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point l. Then the i-th lantern is at the point a__i. The lantern lights all points of the street that are at the distance of at most d from it, where d is some positive number, common for all lanterns.
Vanya wonders: what is the minimum light radius d should the lanterns have to light the whole street?
瓦尼亚深夜沿着一条长度为 l 的笔直街道行走,街道上共有 n 盏路灯。我们建立一个坐标系,使街道起点对应坐标 0,终点对应坐标 l。第 i 盏路灯位于坐标 ai 处。每盏路灯的照明范围是其周围距离不超过 d 的所有点,其中 d 是一个正数,且对所有路灯均相同。
瓦尼亚想知道:为了照亮整条街道,路灯所需的最小照明半径 d 是多少?
输入格式
The first line contains two integers n, l (1 ≤ n ≤ 1000, 1 ≤ l ≤ 109) — the number of lanterns and the length of the street respectively.
The next line contains n integers a__i (0 ≤ a__i ≤ l). Multiple lanterns can be located at the same point. The lanterns may be located at the ends of the street.
第一行包含两个整数 n、l(1 ≤ n ≤ 1000,1 ≤ l ≤ 109)—— 分别表示灯笼的数量和街道的长度。
下一行包含 n 个整数 ai(0 ≤ ai ≤ l)。多个灯笼可以位于同一位置。灯笼可以位于街道的端点处。
输出格式
Print the minimum light radius d, needed to light the whole street. The answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.
输出照亮整条街道所需的最小灯光半径 d。若答案的绝对或相对误差不超过 10−9,则视为正确。
输入输出样例
输入#1
7 15 15 5 3 7 9 14 0
输出#1
2.5000000000
输入#2
2 5 2 5
输出#2
2.0000000000
说明/提示
Consider the second sample. At d = 2 the first lantern will light the segment [0, 4] of the street, and the second lantern will light segment [3, 5]. Thus, the whole street will be lit.
考虑第二个样例。当 d=2 时,第一盏灯笼将照亮街道上的区间 [0,4],第二盏灯笼将照亮区间 [3,5]。因此,整条街道都将被照亮。
输入解题思路,AI测评打分。不知道怎么写?