B题(覆盖问题)
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
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 15
15 5 3 7 9 14 0
2.5000000000
2 5
2 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.
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int n,l;
double s,t,ans,r,u;
int a[];
int main()
{
cin>>n>>l;
double f=;
for(int i=; i<n; i++)
cin>>a[i];
sort(a,a+n);
for(int i=; i<n-; i++)
{
ans=a[i+]-a[i];
if(f<ans)
f=ans;
}
r=f/;
s=a[];
t=(l-a[n-]);
double u=max(s,t);
double v=max(u,r);
printf("%.10lf\n",v);
}
B题(覆盖问题)的更多相关文章
- bzoj1052 9.20考试 第二题 覆盖问题
1052: [HAOI2007]覆盖问题 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2004 Solved: 937[Submit][Statu ...
- c#面试题汇总
下面的参考解答只是帮助大家理解,不用背,面试题.笔试题千变万化,不要梦想着把题覆盖了,下面的题是供大家查漏补缺用的,真正的把这些题搞懂了,才能“以不变应万变”.回答问题的时候能联系做过项目的例子是最好 ...
- 《Java学习笔记(第8版)》学习指导
<Java学习笔记(第8版)>学习指导 目录 图书简况 学习指导 第一章 Java平台概论 第二章 从JDK到IDE 第三章 基础语法 第四章 认识对象 第五章 对象封装 第六章 继承与多 ...
- .NET工程师面试宝典
.Net工程师面试笔试宝典 传智播客.Net培训班内部资料 这套面试笔试宝典是传智播客在多年的教学和学生就业指导过程中积累下来的宝贵资料,大部分来自于学员从面试现场带过来的真实笔试面试题,覆盖了主流的 ...
- 传智播客DotNet面试题
技术类面试.笔试题汇总(整理者:杨中科,部分内容从互联网中整理而来) 注:标明*的问题属于选择性掌握的内容,能掌握更好,没掌握也没关系. 下面的参考解答只是帮助大家理解,不用背,面试题.笔试题千变万化 ...
- 收藏所用C#技术类面试、笔试题汇总
技术类面试.笔试题汇总 注:标明*的问题属于选择性掌握的内容,能掌握更好,没掌握也没关系. 下面的参考解答只是帮助大家理解,不用背,面试题.笔试题千变万化,不要梦想着把题覆盖了,下面的题是供大家查漏补 ...
- 201621123062《java程序设计》第四周作业总结
1. 本周学习总结 1.1 写出你认为本周学习中比较重要的知识点关键词 关键词:重载.继承.多态.static.final.抽象类 1.2 尝试使用思维导图将这些关键词组织起来.注:思维导图一般不需要 ...
- Week04-面向对象设计与继承
1. 本周学习总结 1.1 写出你认为本周学习中比较重要的知识点关键词 is a关系 覆盖 Object 超级父类 继承 抽象类 多态 重载 static super private public p ...
- 201621123050 《Java程序设计》第4周学习总结
1. 本周学习总结 1.1 写出你认为本周学习中比较重要的知识点关键词 继承.抽象.多态 1.2 尝试使用思维导图将这些关键词组织起来.注:思维导图一般不需要出现过多的字. 1.3 可选:使用常规方法 ...
- 201621123040《Java程序设计》第4周学习总结
1.本周学习总结 1.1写出你认为本周学习中比较重要的知识点关键词 关键词:继承 多态性 基本语法 重新定义Override 1.2尝试使用思维导图将这些关键词组织起来.注:思维导图一般不需要出现过多 ...
随机推荐
- [Locked] Sparse Matrix Multiplication
Given two sparse matrices A and B, return the result of AB. You may assume that A's column number is ...
- VGO新闻 - VGO
VGO新闻 - VGO VGO天津伊势丹店盛装揭幕 VGO天津伊势丹店盛装揭幕2013年9月7日,VGO(微高)全国首家实体店在天津伊势丹百货盛装开幕.现场,100多位商场领导及业内同仁共同出席了
- M - 昂贵的聘礼 - poj1062
Description 年轻的探险家来到了一个印第安部落里.在那里他和酋长的女儿相爱了,于是便向酋长去求亲.酋长要他用10000个金币作为聘礼才答应把女儿嫁给他.探险家拿不出这么多金币,便请求酋长降低 ...
- tomcat不用工程名访问怎么配置?
tomcat不用工程名访问配置,直接用域名访问 在 tomcat6的安装路径下,D:\Tomcat-6\conf,修改server.xml文件 编辑Host节点, <Host appBase=& ...
- [深入React] 1. 开发环境搭建
React环境其实很简单(不兼容ie8): <!DOCTYPE html> <html> <head> <title>React</title&g ...
- dubbo源码分析三:consumer注册及生成代理对象
本章我们将分析一下consumer向注册中心注册,并获取服务端相应的信息,根据这些信息生产代理对象的过程和源码. 1.类图 上图展示了部分消费者注册及生成代理对象过程中需要使用到的类和接口,其中: s ...
- CFBundleVersion与CFBundleShortVersionString,版本上架注意事项
CFBundleVersion,标识(发布或未发布)的内部版本号.这是一个单调增加的字符串,包括一个或多个时期分隔的整数. CFBundleShortVersionString 标识应用程序的发布版 ...
- HDU1700:Points on Cycle
Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...
- HDOJ 1787 GCD Again(欧拉函数)
GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- inux 安装中文支持包及中文字符集配置 +i18n
由于某些原因系统安装时未安装中文支持,导致后续应用出现中文方块乱码现象, 解决方法很简单,当然不是重装,只需以下三步即可搞定. .安装中文包: yum -y groupinstall chinese- ...