Codeforces Round #280 (Div. 2) B

Linux单独编译设备树,开发者分享 | Petalinux 工程中设备树的介绍 本文来自XILINX嵌入式产品应用工程师 Terry Ni设备树是 Petalinux kernel 的关键组件,接下来以 2020.1 版本为例,为大家介绍一下在Xilinx Petalinux 工程中的设备树是如何产生,配置以及修改的。Petalinux 工程中设备树的位置当我们创建了一个 petalinux 工程后(以zcu102为例),在编译的时候,会自动生成对应的设备树文件。这些设备树的... 阅读详情

题目:

B. Vanya and Lanterns
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 test(s)
input
7 15
15 5 3 7 9 14 0
output
2.5000000000
input
2 5
2 5
output
2.0000000000
Note

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.


分析:一个长l的街道,在一些指定点上会有一些灯笼,问灯笼最小照亮半径为多少可以照亮整条街。

处理下,相邻元素最大值,注意一下0 or L处没有灯笼的情况。

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <set>
#include <limits>
#include <map>

using namespace std;

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define F(i, n) for(int (i)=0;(i)<(n);++(i))
#define REP(i, s, t) for(int (i)=(s);(i)<=(t);++(i))
#define UREP(i, s, t) for(int (i)=(s);(i)>=(t);--(i))
#define REPOK(i, s, t, o) for(int (i)=(s);(i)<=(t) && (o);++(i))
#define MEM0(addr) memset((addr), 0, sizeof((addr)))

#define PI 3.1415926535897932384626433832795
#define HALF_PI 1.5707963267948966192313216916398

#define MAXN 100000
#define MAXM 10000
#define MOD 1000000007

typedef long long LL;

const double maxdouble = numeric_limits<double>::max();
const double eps = 1e-10;
const int INF = 0x7FFFFFFF;



int a[1005];
int main()
{
    int n,l;
    while(cin>>n>>l)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        int ma = -1;
        for(int i=1;i<n;i++)
        {
            int tmp = a[i] - a[i-1];
            ma = max(tmp,ma);
        }
        int x = 2*(a[0] - 0);
        int y = 2*(l - a[n-1]);
        ma = max(ma,x);
        ma = max(ma,y);
        double ans = (double) ma/2;
        printf("%.10lf\n",ans);
    }
}




android 蓝牙通讯demo android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。 立即下载

相关推荐

PCB设计必看:铜皮厚度与载流能力对照表(附Excel计算工具)

本文深入解析了PCB设计中铜皮厚度与载流能力的核心关系,提供了基于IPC-2152标准的动态计算逻辑与实用Excel工具。文章不仅分享了载流对照表,更重点剖析了影响载流能力的关键因素(如铜厚、线宽、温升、布线层),并给出了高电流设计的实战技巧与测试验证方法,帮助工程师规避常见陷阱,实现从理论到实践的闭环设计。

weixin_29228781的博客 721

Codeforces Round #280 (Div. 2) 解题报告 A.B.C.D.E.

不知道到底是我的水平提高了还是CF的题目变水了。。。。。。 A - Vanya and Cubes 水题。。暴力枚举就可以。。 代码如下: #include #include #include #include #include #include #include #include #include #include #include using namespa

scf0920 1160

主流算力卡性能对比分析

超大规模AI训练/HPC:优先选择NVIDIA H100或AMD MI300X,需关注显存带宽和多卡互联能力。企业级AI训练:NVIDIA A100性价比更高,生态成熟。国内自主可控需求:华为昇腾910B是首选,支持液冷和低功耗设计。本地AI推理/游戏:NVIDIA RTX 4090或RTX 5090性价比突出,但需注意显存容量限制。边缘计算/低功耗场景:华为昇腾310或清微智能TX536(能效比6.3TOPS/W@INT8)更合适。

m0_69867914的博客 7796

Codeforces Round #280 (Div. 2)A B C

A - Vanya and Cubes: #include #include #include using namespace std; typedef __int64 ll; const int N = 10005; ll a[N]; int main() { a[0] = 0; for( ll i = 1; i <= 10000; i++ ) {

uuuuuu 515

告别Quartus II的漫长等待:用VSCode+iverilog+GTKWave搭建你的轻量级Verilog仿真环境(2024保姆级教程)

本文详细介绍了如何利用VSCode、iverilog和GTKWave构建高效的Verilog/SystemVerilog开发环境,替代传统的Quartus II和ModelSim工具。通过2024年最新的保姆级教程,帮助开发者实现秒级启动、低资源消耗的轻量级仿真环境,显著提升数字电路设计的开发效率和调试体验。

weixin_33690963的博客 560

YOLO11实战 第001期-基于yolo11的CrowdHuman密集行人目标检测实战文档(yolo格式数据免费获取)

1.数据阶段在拥挤/遮挡场景下,使用crowdhuman数据集重训练后的yolo11,效果表现较好。crowdhuman数据集标签如下,有Head BBox、Visible BBox、Full BBox。如下图显示:数据集介绍CrowdHuman数据集是旷世发布的用于行人检测的数据集,图片数据大多来自于google搜索。CrowdHuman数据集数据量比较大,15000张,5000张,验证集4370张。训练集和验证集中共有470K个实例,约每张图片包含23个人,同时存在各种各样的遮挡。

深度学习算法工程师,专注于前沿算法研究与实战应用。在这里,我将分享深度学习领域的实战经验、优质数据集资源以及最新论文解读与精度分析,旨在与广大技术爱好者共同探索人工智能的奥秘,助力技术成长与创新。 2161

Codeforces Round #280 (Div. 2) b

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34235135的博客 105

将Keil中的变量数组导出

首先,写好导出数据的函数。

小柚子的博客 1951

Codeforces Round #280 (Div. 2) A B C

http://codeforces.com/contest/492 A 水题 A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

mfcheer 635

17. ADC开发

bes2700 支持2路ADC。

雪飞_海 340

2022年全国职业院校技能大赛 高职组大数据技术与应用卷⑦——解析答案

大数据时代,电商经营模式发生很大改变。在传统运营模式中,缺乏数据积累,人们在做出一些决策行为过程中,更多是凭借个人经验和直觉,发展路径比较自我封闭。而大数据时代,为人们提供一种全新的思路,通过大量的数据分析得出的结果将更加现实和准确。商家可以对客户的消费行为信息数据进行收集和整理,比如消费者购买产品的花费、选择产品的渠道、偏好产品的类型、产品回购周期、购买产品的目的、消费者家庭背景、工作和生活环境、个人消费观和价值观等。通过数据追踪,知道顾客从哪儿来,是看了某网站投放的广告还是通过朋友推荐链接,是新访客还是

我是网络安全兼技能大赛工程师,专注网络安全技术学习与技能大赛实战!持续分享最新的技术文章,帮你少走弯路,一起在技术赛道上进步~ 471

Codeforces Round #280 (Div. 2) A,B,C,D

A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya got n cubes. He decided to build a pyramid fr

mystery_guest的博客 560

51单片机入门指南-基于STC89C52(持续更新)

一、环境介绍 编程IDE: keil5 单片机型号: STC89C51/52 开发板: 普中科技的开发板 完整PDF资源下载地址:https://download.csdn.net/download/xiaolong1126626497/19785856 二、51单片机开发手册介绍 2.1 前言 51单片机是对所有兼容Intel 8031指令系统的单片机的统称。 该系列单片机的始祖是Intel的8004单片机,后来随着Flash rom技术的发展,8004单片机取得了长足的进展,成为应用最.

8797

cf492B--Codeforces Round #280 (Div. 2)B

B. Vanya and Lanternstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVanya walks late at night along a straight street of length l, lit by n lanterns. Consider the coordinate system with the beginning of

qq_62079079的博客 155

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Codeforces Round #280 (Div. 2 A,B,C,D,E)

改了时区之后打cf更辛苦了啊。。。昨天没做,今天补了一下啊。 A. Vanya and Cubes 每次加的数规律性很明显就是:(i+1)*i/2。暴力枚举i就可以得到答案。 #include #include #include #include #include #include #include #include #include #include #include

I am a slow walker, but I never walk backwards! 1156

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Codeforces Round #280 (Div. 2) 解题报告(A B C D E)

A. Vanya and Cubes         思路:累加计算叠到每个高度至少需要多少方块,然后找最后一个满足的即可。 #include #include #include #include #include #include #include #include using namespace std; #define ll long long #define INF 1

A Cube Master 838

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Vanya and Lanterns( Codeforces Round #280 (Div. 2)B)

此题链接单击这里================题意: 在X轴上半轴有n个小岛,给出每个小岛座标。以X轴为圆心画半径为d的圆,问最少画多少个圆才能把所有的小岛覆盖起来。 思路: 这是一个区间选点问题,先以每个小岛为圆心,d为半径,找到圆与X轴相交的左右端点或相切的点(把圆的方程变换一下,变成求x的方程)。求得的所有的区间进行重合判断。(输入的小岛的纵座标一定大于等于d,否定就直接输出-1)

Folieshell的博客 562

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 input output standard output Vanya gotncubes. He decided to build a pyramid ...

weixin_30478923的博客 95

(Vanya and Lanterns)Codeforces Round #280 (Div. 2)B

此题链接单击这里================= 有问题联系企鹅791267032 邮箱地址….wutanrong@Hotmail.com

Folieshell的博客 534

Codeforces Round #280 (Div. 2)B. Vanya and Lanterns(贪心)

题目链接 题意:告诉你借到的长度是L,然后有m个街灯位置,然后问你街灯的半径R至少多大,才能够使整个街道每个位置都有灯光覆盖。 解答:贪心,先计算最大的2个街灯之间的距离,然后再看下端点处 #define CF #ifndef CF #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<st

qwesde 324

Codeforces #280 (Div.2 A~E)

Codeforces Round #280 (Div. 2) A. Vanya and Cubes 题意: Vanya要堆金字塔,第1层要1个方块,第2层要1+2个,第3层要1+2+3个,以此类推。现在Vanya有n个方块,求能堆的金字塔的最大高度。 题解: 设金字塔高度为h,则需要的积木数为\sum_{i = 1} ^ {h} {\sum_{j = 1} ^ {i} {j}

skywalkert's space 1251

Codeforces Round #280 (Div. 2) a

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34396103的博客 84

【codeforces】Codeforces Round #280 (Div. 2) 水题专场

传送门:【codeforces】Codeforces Round #280 (Div. 2) 492A. Vanya and Cubes 找到最大的i使得1+2+3+……+i小于等于n,并且输出i。 #include #include #include using namespace std ; typedef long long LL ; #define rep( i ,

poursoul 793

Codeforces Round #280 (Div. 2) c

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34247299的博客 109

Codeforces Round #280 (Div. 2)

A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya got n cubes. He decided to build a pyramid

一点也不二 1061

Codeforces Round #280 (Div. 2) d

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34061042的博客 81
上一篇: Codeforces Round #280 (Div. 2) A
下一篇: Codeforces Round #280 (Div. 2) C
Notdeep__acm
博客等级 码龄12年 20粉丝 53原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值