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. thinkphp分页样式

    html代码: <div class="pages">{$page}</div> css代码: .pages{ width:100.5%; text-ali ...

  2. hdu 4055 递推

    转自:http://blog.csdn.net/shiqi_614/article/details/7983298 题意:由数字1到n组成的所有排列中,问满足题目所给的n-1个字符的排列有多少个,如果 ...

  3. [Liferay6.2]启动Tomcat提示APR不能在java类库路径中被找到的解决办法

    问题描述 启动liferay之后,在控制台中打印出会打印出以下信息: 信息: The APR based Apache Tomcat Native library which allows optim ...

  4. 初探Docker

    本文旨在让大家了解什么是Docker,并带领大家体验Docker使用的整个流程. 开启Docker学习之旅前,我们简单描述几个场景,应该很多人都有碰到过: 小凹同学开发了一个web应用,服务器环境是: ...

  5. CentOS配置本地yum源(使用镜像iso文件)

    本人在使用yum安装软件的时候,感觉最不爽的是网络不佳时,安装的速度特别慢.所以,个人就上网search了一下如何使用Linux的安装文件作为其yum源.经过几次尝试,已经可以成功的配置了.下面是详细 ...

  6. Linux将文件拷到u盘

    1:终端中获取root后,使用fdisk -l来查看位置 2:挂载u盘:mount /路径 /mnt cd /mnt可进入u盘,ls可查看文件 3:复制:cp /(文件路径) /mnt 4:退出u盘: ...

  7. 用padding与margin做多个元素的等间距分布

    这样做的好处是不管有多少个元素等间距分布,都可以直接写在li中,而且由于是给a设定的样式,所以在字数不一致的情况下,样式仍然是统一的. html: <!DOCTYPE html> < ...

  8. JQuery学习之操作CSS

    样式表: .important{ font-weight:bold; font-size:xx-large; } .blue{ color:blue; } 1.addClass():向被选元素添加一个 ...

  9. css -- 映像 ,分页(上一页下一页)

    1.映像:-webkit-box-reflect:blow 2px -webkit-gradient( linear, left top, left bottom, from(transparent) ...

  10. WPF,解决Listbox,按住ListboxItem向下拖出Listbox,横向滚动条跑到最后。

    类似这种样式的控件,.,在横向滚动条隐藏的情况下有这样的问题.(横向滚动条显示的时候也会,,目前不知道怎么解决.) 因为这个控件偏移是利用ListBox的ItemsPanelTemplate模版里的S ...