Description

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 ai. 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?

Input

The first line contains two integers nl (1 ≤ n ≤ 1000, 1 ≤ l ≤ 109) — the number of lanterns and the length of the street respectively.

The next line contains n integers ai (0 ≤ ai ≤ l). Multiple lanterns can be located at the same point. The lanterns may be located at the ends of the street.

Output

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.

Sample Input

Input
7 15 
15 5 3 7 9 14 0
Output
2.5000000000
Input
2 5 
2 5
Output
2.0000000000

Hint

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.

题意:一条街,起点0,长度L。在街上有多盏灯,每盏灯的照亮半径一样,求最小半径使得整个街道都是亮的...(可以一个位子放多盏灯,0和L点都可以放灯)

解题思路:    第一种情况,0和L都有放灯,那么答案就是求相邻两盏灯之间的最大距离的一半,因为只有这样才可能照亮整个街道。就可木桶原理差                                不多。

      第二种情况,首尾有可能没有放,或者只放了一个,就和案例2一样(位置0到第一个灯的距离为2大于用情况一求的0.5,所以答案就是                               2)

      这样的话 就可以总结下,只要求出相邻最大的距离的一半,然后和位置0到第一个灯的距离c1,以及最后一个灯到L的距离c2。他们进行                                    比较 ,最后输出他们三个中最大值就好了 

代码如下:(额 忘记说了 ,还要排个序.....)

 #include <stdio.h>
#include <algorithm>
using namespace std;
int a[];
int main()
{
int n,l,q,c1,c2;
while(scanf("%d%d",&n,&l)!=EOF)
{
double r=,ans=;
for(int i=; i<n; i++)
scanf("%d",&a[i]);
sort(a,a+n);
for(int i=; i<n; i++)
{
q=a[i]-a[i-];
if(q>r) r=q;
}
c1=a[];
c2=l-a[n-];
ans=max(c1,c2);
ans=max(r/,ans);
printf("%.10lf\n",ans);
}
return ;
}

  

      

      

CodeForces 492B的更多相关文章

  1. Codeforces 492B B. Vanya and Lanterns

    Codeforces  492B   B. Vanya and Lanterns 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...

  2. codeforces 492B. Vanya and Lanterns 解题报告

    题目链接:http://codeforces.com/problemset/problem/492/B #include <cstdio> #include <cstdlib> ...

  3. Codeforces 492B Name That Tune ( 期望DP )

    B. Name That Tune time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  4. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  7. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  8. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  9. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

随机推荐

  1. 高德地图 JavaScript API 开发系列教程(一)

    高德地图 API 提供包括 Web API 即 JavaScript API,Android API,定位API,IOS API,WP API,Win8 API等,本系列教程主要针对高德 JavaSc ...

  2. Linux vsftp

    本机环境CentOS-6.6-i386-bin-DVD1.iso安装盘.安装时选择minimal模式.本机IP地址配置为192.168.0.211. 1.查询系统是否已安装了vsftpd [root@ ...

  3. 怎么删除远程登录连接的ip

    通过远程桌面可以登录到远程电脑上进行相应的操作,在登录过后会在本地电脑上留下登录过的IP以及登录用户名相关信息,可能会给远程的电脑带来安全隐患,下面介绍一下清除远程桌面历史记录的方法. 1.删除我的文 ...

  4. 【约瑟夫环变形】UVa 1394 - And Then There Was One

    首先看到这题脑子里立刻跳出链表..后来继续看如家的分析说,链表法时间复杂度为O(n*k),肯定会TLE,自己才意识到果然自个儿又头脑简单了 T^T. 看如家的分析没怎么看懂,后来发现这篇自己理解起来更 ...

  5. poj 3678 2-SAT问题

    思路:将每个点拆分为两个点 a与a' ,a表示为1,a'表示为0.那么条件给的每个边自然就会存在矛盾,然后根据2-SAT建边就行了. #include<iostream> #include ...

  6. 跟我一起学习VIM - The Life Changing Editor

    前两天同事让我在小组内部分享一下VIM,于是我花了一点时间写了个简短的教程.虽然准备有限,但分享过程中大家大多带着一种惊叹的表情,原来编辑器可以这样强大,这算是对我多年来使用VIM的最大鼓舞吧.所以分 ...

  7. BZOJ 3831

    3831: [Poi2014]Little Bird Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 121  Solved: 68[Submit][S ...

  8. ActionBar 的简单使用

    About ActionBar The action bar is one of the most important design elements you can implement for yo ...

  9. 第一篇:groovy对DSL的语法支持

    引子 我们用一段gradle的脚本做引子,理解这一段脚本与一般的groovy代码是怎么联系起来的 buildscript { repositories { jcenter() mavenLocal() ...

  10. (二)Qt界面设计之菜单栏

    1.添加菜单项 直接输入菜单项名称,然后回车即可. 2.为菜单项设置图标 在动作编辑器上,右键选择编辑,然后添加图标 如果想在图标栏添加该菜单的快捷图标,直接将该动作项拖放只图标栏即可. 3.事件响应 ...