Lanterns

题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/B

题目:

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 1515 5 3 7 9 14 0
Output
2.5000000000
Input
   2 5
   2 5
Output
2.0000000000

题意:    有一条长为L的街道,N盏灯要全部照亮整条街道,求灯的最少照亮半径。分析:    求出相邻两盏灯之间最远的距离即可。      注意:第一盏灯与街头距离和最后一盏灯与街尾的距离。
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
;
 double a[maxn];
int main()
{
   int n,i;
   double l;
    cin>>n>>l;
        a[]=;
     ;i<=n;i++)
       cin>>a[i];
     sort(a,a+n+);
     a[n+]=l;
     ]-a[])*;
     ;i<n+;i++)
     {
     ]>m)
         m=a[i]-a[i-];
     }
     ]-a[n])*>m)
         m=(a[n+]-a[n])*;
      printf();
   ;
}

 
 

Lanterns的更多相关文章

  1. HDU 3364 Lanterns 高斯消元

    Lanterns Problem Description   Alice has received a beautiful present from Bob. The present contains ...

  2. cf492B Vanya and Lanterns

    B. Vanya and Lanterns time limit per test 1 second memory limit per test 256 megabytes input standar ...

  3. Codeforces 492B B. Vanya and Lanterns

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

  4. Vanya and Lanterns

    Description Vanya walks late at night along a straight street of length l, lit by n lanterns. Consid ...

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

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

  6. HDU3364 Lanterns(求矩阵的秩)

    求矩阵的秩,及判断有无解 #include<cstdio> #include<iostream> #include<cstdlib> #include<cst ...

  7. HDU 3364 Lanterns (高斯消元)

    题意:有n个灯和m个开关,每个开关控制数个灯的状态改变,给出k条询问,问使灯的状态变为询问中的状态有多少种发法. 析:同余高斯消元法,模板题,将每个开关控制每个灯列成行列式,最终状态是结果列,同余高斯 ...

  8. [Gauss]HDOJ3364 Lanterns

    题意:有n个灯笼,m个开关 每个开关可以控制k个灯笼, 然后分别列出控制的灯笼的编号(灯笼编号为1到n) 下面有Q个询问,每个询问会有一个最终状态(n个灯笼为一个状态)0代表关 1代表开 问到达这种状 ...

  9. 3364 Lanterns (异或方程组高斯消元)

    基本思路.首先构造一个n*(m+1)的矩阵,同时标记一个行数row,row从零开始,然后找出每一列第一个非零的数,和第row行互换, 然后对row到n行,异或运算.最终的结果为2^(m-row) #i ...

随机推荐

  1. [SQL]查询及删除重复记录的SQL语句

    一:查询及删除重复记录的SQL语句1.查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断select * from peoplewhere peopleId in (select ...

  2. 关于ICE

    转自:http://wenda.chinabaike.com/b/38322/2013/1103/614756.html 一.ICE产生的背景 基于信令协议的多媒体传输是一个两段式传输.首先,通过信令 ...

  3. Effective C++ 之 Item 6 : 若不想使用编译器自动生成的函数,就该明确拒绝

    Effective C++ chapter 2. 构造 / 析构 / 赋值运算 (Constructors, Destructors, and Assignment Operators) Item 6 ...

  4. mysql中sql语句

    <数据定义语言DDL> 一. create TABLE tableName 创建表 二. alter TABLE tableName 修改表 三. drop TBALE tableName ...

  5. 使用lsof查看进程句柄使用情况

    lsof -n |awk '{print $2}'|sort|uniq -c |sort -nr|more

  6. C语言中float如何存储?

    float 内存如何存储的 类型 存储位数 总位数 偏移值 (offset) 数符(S) 阶码(E) 尾数(M) 短实数(float) 1 8 23 32 127 长实数(double) 1 11 5 ...

  7. springMVC 的工作原理和机制(转)

    工作原理上面的是springMVC的工作原理图: 1.客户端发出一个http请求给web服务器,web服务器对http请求进行解析,如果匹配DispatcherServlet的请求映射路径(在web. ...

  8. hdu1248完全背包

    不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前.死亡骑士:"我要买道具!" ...

  9. HTML DOM学习之二

    1.HTML DOM属性: **innerHTML属性-获取元素内容的最简单方法是使用innerHTML属性,innerHTML属性对于获取或替换HTML元素的内容很有用 <html> & ...

  10. 自定义鼠标光标,制作cur,设置热点,中心点。

    ..没哈好说的,,只是推荐一个软件 ArtCursor..非常好用. 关于另外一个更改光标的重要问题:鼠标的hotspot,也就是鼠标的作用点问题,本人关于这个问题纠结了很久,始终无法找到更改HCUR ...