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 ...
随机推荐
- [NOIP 2005]-- 篝火晚会
额~~,对这组题感兴趣的具体的解题报告可以戳戳这里:http://wenku.baidu.com/view/878beb64783e0912a2162aa7.html?qq-pf-to=pcqq.c2 ...
- java.util.zip.Deflater 压缩 inflater解压 实例
原文:java压缩解压缩类实例[转] package com.example.helloworld; import java.io.ByteArrayOutputStream; import java ...
- 基于Sql Server 2008的分布式数据库的实践(五)
原文 基于Sql Server 2008的分布式数据库的实践(五) 程序设计 ------------------------------------------------------------- ...
- zoj 2277 The Gate to Freedom
N^N = X ---> Nlog10(N) = log10( X ) ----> X的最高位为 Nlog10(N) 小数部分的第一个非0位 #include<stdio ...
- 利用JNI技术在Android中调用C++形式的OpenGL ES 2.0函数
1. 打开Eclipse,File-->New-->Project…-->Android-->AndroidApplication Projec ...
- Sqlite ContentProvider Loader 上下文 对话框
一.整体工程图 二.activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/re ...
- Java进阶04 RTTI
链接地址:http://www.cnblogs.com/vamei/archive/2013/04/14/3013985.html 作者:Vamei 出处:http://www.cnblogs.com ...
- mysql入门记录
mysql -h localhost(or ID) -u root -p show databases; create database <数据库名>: drop database < ...
- 配置Jenkins的slave节点的详细步骤适合windows等其他平台(转)
@ 新建一个slave节点在Jenkins服务器上 1,进入Jenkins的主界面,进入“Manage Jenkins” 页面: 2,点击如下图中的“Manage Nodes”: 3,进入页面后点 ...
- python中打印文件名,行号,路径
print "I have a proble! And here is at Line: %s"%sys._getframe().f_lineno PDB,哈哈http://doc ...