Vanya and Lanterns
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 52 5
2.0000000000
Hint
Consider the second sample. At d = 2 the first lantern will light the segment [0, 4] of the street, and the second lantern will light segment [3, 5]. Thus, the whole street will be lit.
其实只要 求出最大 间距 再除以2 就是 半径了
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
];
int n,l;
int main(){
while(cin>>n>>l&&n){
;i<n;i++){
scanf("%lf",x+i);
}
sort(x,x+n);
;
;i<n;i++){
ma=max(ma,x[i]-x[i-]);
}
ma/=;
ma=max(ma,x[]);
ma=max(ma,l-x[n-]);
printf("%0.10f",ma);
}
;
}
Vanya and Lanterns的更多相关文章
- 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= ...
- codeforces 492B. Vanya and Lanterns 解题报告
题目链接:http://codeforces.com/problemset/problem/492/B #include <cstdio> #include <cstdlib> ...
- Codeforces Round #280 (Div. 2) A B C 暴力 水 贪心
A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- CodeForces Round #280 (Div.2)
A. Vanya and Cubes 题意: 给你n个小方块,现在要搭一个金字塔,金字塔的第i层需要 个小方块,问这n个方块最多搭几层金字塔. 分析: 根据求和公式,有,按照规律直接加就行,直到超过n ...
- Codeforces Round #280 (Div. 2) A , B , C
A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- [codeforces] 暑期训练之打卡题(一)
每个标题都做了题目原网址的超链接 Day1<Vanya and Lanterns> 题意: 一条长度为 l 的街道,在这条街道上放置了n个相同的灯,街道一端位置记为0,每个灯的位置在ai处 ...
- Lanterns
Lanterns 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/B 题目: Description ...
- codeforces C. Vanya and Scales
C. Vanya and Scales Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w10 ...
随机推荐
- [HDU 2553]--N皇后问题(回溯)/N皇后问题的分析
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2553 N皇后问题 Time Limit: 2000/1000 MS (Java/Others) ...
- [Swust OJ 247]--皇帝的新衣(组合数+Lucas定理)
题目链接:http://acm.swust.edu.cn/problem/0247/ Time limit(ms): 1000 Memory limit(kb): 65535 Descriptio ...
- 性能测试工具:AB
###################################################################################格式:ab -n 请求次数 -c ...
- iOS8 UITableView 分割条设置separator intent = 0 不起作用
转自:http://blog.csdn.net/ljb_wh/article/details/40788333 ios7的时候在storyboard 设置 TableView的separator in ...
- java.util.zip.Deflater 压缩 inflater解压 实例
原文:java压缩解压缩类实例[转] package com.example.helloworld; import java.io.ByteArrayOutputStream; import java ...
- Pencil OJ 02 安装
Mongo 官方的安装方法 官方教程已经很好啦,这里就不罗嗦了. 源码编译 待补.我是从这里看到的. 遇到的问题 启动时的警告信息 2015-03-06T21:01:15.526-0800 I CON ...
- Acitivity创建与配置
•Activity的创建和配置 –Activity提供了和用户交互的可视化界面.创建一个Activity一般是继承Activity(当然也可以继承ListActivity.MapActivity等), ...
- LDAP研究
一.ldap介绍 ldap是轻量级的文件夹訪问协议.重点是文件夹訪问协议.更为重点的是协议.好吧他是一个协议.也就是一个标准. 那么实现这款协议的软件当中有一款就是openldap. 二.安装wind ...
- IntelliJ IDEA 开发swing(二)
原文:idea开发swing(二) 闲话少说,书接idea开发swing(一). 程序编译完成后,需要打包发布,如果有fat_jar的同学可以通过该插件打包,这里是使用ant来打包,步骤如下: 一.编 ...
- jQuery 简单滑动轮播图效果
一般页面简单轮播图效果用jQuery制作更加简单.我们来看看以下效果是如何来进行制作的. 其html结构下所示: <div id="box"> < ...