Lanterns
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 n, l (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
7 1515 5 3 7 9 14 0
2.5000000000
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的更多相关文章
- HDU 3364 Lanterns 高斯消元
Lanterns Problem Description Alice has received a beautiful present from Bob. The present contains ...
- cf492B Vanya and Lanterns
B. Vanya and Lanterns time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces 492B B. Vanya and Lanterns
Codeforces 492B B. Vanya and Lanterns 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...
- Vanya and Lanterns
Description Vanya walks late at night along a straight street of length l, lit by n lanterns. Consid ...
- codeforces 492B. Vanya and Lanterns 解题报告
题目链接:http://codeforces.com/problemset/problem/492/B #include <cstdio> #include <cstdlib> ...
- HDU3364 Lanterns(求矩阵的秩)
求矩阵的秩,及判断有无解 #include<cstdio> #include<iostream> #include<cstdlib> #include<cst ...
- HDU 3364 Lanterns (高斯消元)
题意:有n个灯和m个开关,每个开关控制数个灯的状态改变,给出k条询问,问使灯的状态变为询问中的状态有多少种发法. 析:同余高斯消元法,模板题,将每个开关控制每个灯列成行列式,最终状态是结果列,同余高斯 ...
- [Gauss]HDOJ3364 Lanterns
题意:有n个灯笼,m个开关 每个开关可以控制k个灯笼, 然后分别列出控制的灯笼的编号(灯笼编号为1到n) 下面有Q个询问,每个询问会有一个最终状态(n个灯笼为一个状态)0代表关 1代表开 问到达这种状 ...
- 3364 Lanterns (异或方程组高斯消元)
基本思路.首先构造一个n*(m+1)的矩阵,同时标记一个行数row,row从零开始,然后找出每一列第一个非零的数,和第row行互换, 然后对row到n行,异或运算.最终的结果为2^(m-row) #i ...
随机推荐
- [Monitor] 监控规则定义
系统监控规则:
- 解决linux下unzip中文有乱码的问题
xxx.zip 中有中文的文件,在linux下unzip就会有乱码. 解决办法:安装7zip 去http://sourceforge.net/projects/p7zip/files/latest/d ...
- linux系统定时任务
crontab常用的几个命令如下 sudo crontab -l #显示所有的定时任务 sudo crontab -e #编辑任务 sudo crontab -r #删除所有的任务 编辑任务时的书写方 ...
- Vue#Class 与 Style 绑定
绑定HTMLCLASS 在我没看这之前,我觉得要写绑定class ,应该像绑定数据一样这么写 class ={{class-a}} 看官方教程时,不推荐这么写,推荐这样 v-bind:class=&q ...
- Redis学习笔记(1) Redis介绍及基础
1. Redis的特性 (1) 存储结构 Redis(Remote Dictionary Server,远程字典服务器)是以字典结构存储数据,并允许其他应用通过TCP协议读写字典中的内容.Redis支 ...
- 【SSH】 之 Struts2环境搭建及简单应用开发
在上一篇文章中,我们一起了解了一下struts2的工作机制原理,接下来让我们进行一下简单应用的开发 (一)配置环境 1.建立web项目 2.导入jar包 其中struts2中有很多jar包,我们不需要 ...
- Understanding, Operating and Monitoring Apache Kafka
Apache Kafka is an attractive service because it's conceptually simple and powerful. It's easy to un ...
- Windows下MySQL zip版的简单安装
1.下载MySQL-5.5.10-win32.zip的版本.2.解压到任意路径,比如"D:\Programm Files\".3.进入MySQL路径,复制my-small.ini为 ...
- 【maven】maven各种奇葩问题
问题1:Could not calculate build plan: Plugin org.apache... 不能成功创建maven项目 解决方法1: http://repo1.maven.org ...
- mysql一些有用的链接
1.mysql安装:http://jingyan.baidu.com/article/f79b7cb35c0f439144023e38.html