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. 第四篇:SOUI资源文件组织

    什么是资源? 现代的软件只要有UI,基本上少不了资源. 资源是什么?资源就是在程序运行时提供固定的数据源的文件. 在MFC当道的时代,资源一般就是位图(Bitmap),图标(Icon),光标(Curs ...

  2. WebStorm中将Project分享到GitHub时报“Error Running Git”错误的解决办法

    错误信息 Cannot run program "git.exe":CreateProcess error=2,系统找不到指定的文件. 解决办法 从错误信息就可以知道,WebSto ...

  3. 【java基础】内存分析

    在上次我们说的<重载与重写>呢,我们遗留了一个问题,就是运行结果的各异性,那今天,我们就来探究一下         内存里的天地.                  首先呢,我们把mian ...

  4. 对于一个负数mod正数

    鸟神说.. a/b靠零取整 然后呢..a%b定义成a-(a/b)*b c语言就是这么算的... 那么python2.6是怎么算的呢 如果最后你取模想得到一个正数.. 那么在上述取模定义不变的情况下 p ...

  5. TextView展开和收回

    第一步:接口请求返回数据 第二步:使用handler和textview.getLineCount方法判断是否超过指定行数: community_desc_more.setVisibility(View ...

  6. cf 106C

    题目链接:http://vjudge.net/contest/139376#problem/E 题意看注释就能懂了,求能获得的最大价值. 代码: #include<iostream> #i ...

  7. 程序员必备的代码审查(Code Review)清单【转载】

    在我们关于高效代码审查的博文中,我们建议使用一个检查清单.在代码审查中,检查清单是一个非常好的工具——它们保证了审查可以在你的团队中始终如一的进行.它们也是一种保证常见问题能够被发现并被解决的便利方式 ...

  8. 让Docker使用国内的镜像服务

    使用 Docker 的时候,需要经常从官方获取镜像,但是由于显而易见的网络原因,拉取镜像的过程非常耗时,严重影响使用 Docker 的体验.因此 DaoCloud 推出 Docker 加速器解决这个难 ...

  9. 差分约束系统 POJ 3169 Layout

    题目传送门 题意:有两种关系,n牛按照序号排列,A1到B1的距离不超过C1, A2到B2的距离不小于C2,问1到n的距离最大是多少.如果无限的话是-2, 如果无解是-1 分析:第一种可以写这样的方程: ...

  10. Codeforces Round #332 (Div. 2)

    水 A - Patrick and Shopping #include <bits/stdc++.h> using namespace std; int main(void) { int ...