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 ...
随机推荐
- hdu 4070 福州赛区网络赛J 贪心 ***
优先发路程最长的 #include<cstdio> #include<iostream> #include<algorithm> #include<cstri ...
- 跟着鸟哥学Linux系列笔记0-扫盲之概念
相关缩写全称: POSIX(Portable Operation System Interface):可携式操作系统接口,重点在于规范内核与应用之间的接口,由IEEE定义发布 IEEE: 美国电气与电 ...
- MySQL5.7中新增的JSON类型的使用方法
创建表json_test: CREATE TABLE json_test(id INT(11) AUTO_INCREMENT PRIMARY KEY,person_desc JSON)ENGINE I ...
- Arduino101学习笔记(十四)—— Flash库
一.一些API 1.打开文件 SerialFlashFile file; file = SerialFlash.open("filename.bin"); if (file) { ...
- API和系统调用实现同一方法
“平安的祝福 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 ” 一.基 ...
- 圆形图片CircleImageView
github源码路径: https://github.com/hdodenhof/CircleImageView 第一步:将CircleImageView复制 第二步:将attrs.xml复制 第三步 ...
- Javaweb三大组件之过滤器filter
Filter的三个方法 void init(FilterConfig):在Tomcat启动时被调用: void destroy():在Tomcat关闭时被调用: void doFilter(Servl ...
- AndroidTips:selector的disable状态为什么无效?
正确的姿势: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android=& ...
- 安装PyMysql的基本步骤
X:\Users\**>c: c:\>cd python c:\Python>python ez_setup.py Downloading https://pypi.io/packa ...
- 模数转换(A/D)和数模转换(D/A) 图示
(从书中截图) 在时间域和频率域中示意图: 1.A/D转换 2.D/A转换