AC日记——The Meeting Place Cannot Be Changed codeforces 780b
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的更多相关文章
- 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 ...
- AC日记——codevs1688求逆序对
AC日记--codevs1688求逆序对 锵炬 掭约芴巷 枷锤霍蚣 蟠道初盛 到被他尽情地踩在脚下蹂躏心中就无比的兴奋他是怎么都 ㄥ|囿楣 定要将他剁成肉泥.挫骨扬灰跟随着戴爷这么多年刁梅生 圃鳋 ...
- 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 ...
- Cf Round #403 B. The Meeting Place Cannot Be Changed(二分答案)
The Meeting Place Cannot Be Changed 我发现我最近越来越zz了,md 连调程序都不会了,首先要有想法,之后输出如果和期望的不一样就从输入开始一步一步地调啊,tmd现在 ...
- 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 ...
- Codeforces 782B The Meeting Place Cannot Be Changed(二分答案)
题目链接 The Meeting Place Cannot Be Changed 二分答案即可. check的时候先算出每个点可到达的范围的区间,然后求并集.判断一下是否满足l <= r就好了. ...
- codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)
B. The Meeting Place Cannot Be Change ...
- 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 ...
- 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 ...
随机推荐
- android 文件保存
将数据保存在外部存储器上 /* Checks if external storage is available for read and write */ public boolean isExter ...
- Google Chrome 自定义协议(PROTOCOL)问题的处理
最近在使用谷歌浏览器的时候遇到了自定义协议(PROTOCOL)的问题,比较折腾,特此记录,希望我浪费生命换来的结果能够帮助读到此文的朋友少浪费一点宝贵的时间! 由于某些原因,电脑里一直没有安装阿里旺旺 ...
- groupNoAdj
public boolean groupNoAdj(int start, int[] nums, int target) { if( start >= nums.length){ return ...
- 《数据结构与算法分析:C语言描述》复习——第六章“排序”——冒泡排序
2014.06.17 01:04 简介: 冒泡排序是O(n^2)级别的交换排序算法,原理简单,属于必知必会的基础算法之一. 思路: 排序要进行N轮,每一轮从尾部逐个向前扫描,遇到逆序对就进行交换.确保 ...
- win10系统安装之GHOST还原(转+编辑)
注意*:在以下操作中,你可能需要分区你的原来系统盘,如果是重装的话.现在我们使用SSD固态做系统盘盘,这个分区的话,点选mbr重新引导,以及对齐复选框. 如果前面过程都没问题,在安装过程中出现 ...
- java开发环境的安装
1.Java是一门面向对象的编程语言,由sun公司开发的,目前公司已经被oracle公司收购.那么作为一门编程语言,它有自己的编程环境.并不是你编写了java代码后,就能在任何平台上运行,它的运行有自 ...
- 浅谈传输层协议TCP和UDP
在当今因特网的层次结构中,传输层的协议主要有两种,其一为Transmission Control Protocol,即TCP:其二为User Datagram Protocol,即UDP. 1.TCP ...
- 在Struts2 Action中快速简便的访问Request、Session等变量
前言——正常情况下如何在Action中获取到这些变量 全部方法(共四种)可以参考:http://blog.csdn.net/itmyhome1990/article/details/7019476 这 ...
- user-select & css
user-select & css https://developer.mozilla.org/en-US/docs/Web/CSS/user-select https://css-trick ...
- P3153 [CQOI2009]跳舞
题目描述 一次舞会有n个男孩和n个女孩.每首曲子开始时,所有男孩和女孩恰好配成n对跳交谊舞.每个男孩都不会和同一个女孩跳两首(或更多)舞曲.有一些男孩女孩相互喜欢,而其他相互不喜欢(不会”单向喜欢“) ...