780B - The Meeting Place Cannot Be Changed

思路:

  二分答案;

代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; #define eps 1e-7
#define INF 1e18
#define maxn 60005 int n; double xi[maxn],sp[maxn]; bool check(double ti)
{
double l=-INF,r=INF;
for(int i=;i<=n;i++)
{
l=max(l,xi[i]-sp[i]*ti);
r=min(r,xi[i]+sp[i]*ti);
}
if(l<=r) return true;
else return false;
} int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%lf",&xi[i]);
for(int i=;i<=n;i++) scanf("%lf",&sp[i]);
double l=,r=1e9,ans;
while(l<=r)
{
double mid=(l+r)/2.0;
if(check(mid)) r=mid-eps,ans=mid;
else l=mid+eps;
}
printf("%.7lf",ans);
return ;
}

AC日记——The Meeting Place Cannot Be Changed codeforces 780b的更多相关文章

  1. codeforces 782B The Meeting Place Cannot Be Changed (三分)

    The Meeting Place Cannot Be Changed Problem Description The main road in Bytecity is a straight line ...

  2. AC日记——codevs1688求逆序对

    AC日记--codevs1688求逆序对 锵炬 掭约芴巷 枷锤霍蚣 蟠道初盛 到被他尽情地踩在脚下蹂躏心中就无比的兴奋他是怎么都 ㄥ|囿楣 定要将他剁成肉泥.挫骨扬灰跟随着戴爷这么多年刁梅生 圃鳋 ...

  3. code force 403B.B. The Meeting Place Cannot Be Changed

    B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megab ...

  4. Cf Round #403 B. The Meeting Place Cannot Be Changed(二分答案)

    The Meeting Place Cannot Be Changed 我发现我最近越来越zz了,md 连调程序都不会了,首先要有想法,之后输出如果和期望的不一样就从输入开始一步一步地调啊,tmd现在 ...

  5. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) B. The Meeting Place Cannot Be Changed

    地址:http://codeforces.com/contest/782/problem/B 题目: B. The Meeting Place Cannot Be Changed time limit ...

  6. Codeforces 782B The Meeting Place Cannot Be Changed(二分答案)

    题目链接 The Meeting Place Cannot Be Changed 二分答案即可. check的时候先算出每个点可到达的范围的区间,然后求并集.判断一下是否满足l <= r就好了. ...

  7. codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)

                                                                   B. The Meeting Place Cannot Be Change ...

  8. CodeForce-782B The Meeting Place Cannot Be Changed(高精度二分)

    https://vjudge.net/problem/CodeForces-782B B. The Meeting Place Cannot Be Changed time limit per tes ...

  9. B. The Meeting Place Cannot Be Changed

    B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megab ...

随机推荐

  1. Django将queryset转为json对象

  2. 《数据结构与算法分析:C语言描述》复习——第七章“哈希”——哈希表

    2014.06.22 12:36 简介: 哈希是一种数学思想,将不定长数据通过函数转换为定长数据.不定长数据通常意味着碎片化,动态分配内存等等影响存储和性能的因素.当这个定长数据是一个无符号整数时,可 ...

  3. Lua语言中文手册 转载自网络

    Programming in LuaCopyright ® 2005, Translation Team, www.luachina.net Programming in LuaProgramming ...

  4. 【转载】Linux下安装LoadRunner LoadGenerator

    原文地址:[转载]Linux下安装LoadRunner LoadGenerator作者:邱建忠tester LR的负载机安装在linux的理由: 1.windows xp,双核+4G内存,基本上每个v ...

  5. winform-windowsmediaplayer设置可视化效果之条形

    winform导入windowsmediaplayer这个COM组件,他的默认可视化效果为: 而我们需要的可视化效果为: 则我们可以通过代码更改可视化效果:(参数value设为4即可!) //设置可视 ...

  6. 孤荷凌寒自学python第八天 初识Python的序列之元组

    孤荷凌寒自学python第八天 Python的序列之元组 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) (同步音频笔记:https://www.ximalaya.com/keji/19103 ...

  7. 剑指offer-重建二叉树04

    题目描述 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树.假设输入的前序遍历和中序遍历的结果中都不含重复的数字.例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7, ...

  8. jquery serialize() 方法

    ajax异步提交的时候,会使用该方法. 方法:jQuery ajax - serialize() 方法

  9. Application_Start事件中用Timer做一个循环任务

    protected void Application_Start(object sender, EventArgs e) { System.Timers.Timer timer = new Syste ...

  10. Linux 网卡特性配置ethtool详解

    近期遇到一个自定义报文传输性能问题,解决过程中借助了ethtool这个工具,因此发掘一下与此工具相关的网卡的一些特性. ethtool 常用命令如下,比如对eth0的操作: ethtool eth0 ...