题解 | #路灯#
路灯
http://www.nowcoder.com/practice/62cdf520b9d94616b6644ac03a0306ff
#include <stdio.h>
int main()
{
int n,l;
while(~scanf("%d %d\n",&n,&l))
{
int s[1001];
for(int i=0;i<n;i++)
{
scanf("%d ",&s[i]);
}
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
if(s[i] > s[j])
{
int t = s[i];
s[i] = s[j];
s[j] = t;
}
}
}
double max = s[0]-0;
if(l-s[n-1] > max)
{
max = l-s[n-1];
}
for(int i=1;i<n-1;i++)
{
if((double)(s[i]-s[i-1])/2 > max)
{
max = (double)(s[i]-s[i-1])/2;
}
if((double)(s[i+1]-s[i])/2 > max)
{
max = (double)(s[i+1]-s[i])/2;
}
}
printf("%.2lf\n",max);
}
}