链接:http://codeforces.com/problemset/problem/782/B

题意: N个点,需要找到一个点使得每个点到这个点耗时最小,每个点都同时开始,且都拥有自己的速度

题解: 对于一个确定的位置,如果耗时最久的点在右边,则这个位置可以往右靠,否则就往左靠,这样,一个二分的解法就形成了

import java.lang.Math;
import java.util.Scanner; public class CodeForces_403_B {
private static final int N = (int) 6e4 + 10;
static int a[] = new int[N];
static int v[] = new int[N];
static double eps = 1e-6; public static void main(String args[]) {
// System.out.println("dfwaed");
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = sc.nextInt();
for (int i = 0; i < n; i++)
a[i] = sc.nextInt();
for (int i = 0; i < n; i++)
v[i] = sc.nextInt(); double l = 1, r = Double.MAX_VALUE, tmp = 0, tmp1, ans = 0;
int tmp2 = 0;
while (Math.abs(r - l) > eps) { double mid = (l + r) / 2;
tmp = Double.MIN_VALUE;
for (int i = 0; i < n; i++) {
tmp1 = Math.abs(a[i] - mid) / v[i];
if (tmp1 > tmp) {
tmp = tmp1;
tmp2 = i;
}
} if ((double) a[tmp2] > mid) {
l = mid;
ans = tmp;
} else
r = mid;
}
System.out.printf("%.6f\n", ans);
}
sc.close();
}
}

782B The Meeting Place Cannot Be Changed(二分)的更多相关文章

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

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

  2. 782B. The Meeting Place Cannot Be Changed 二分 水

    Link 题意:给出$n$个坐标$x_i$,$n$个速度$v_i$问使他们相遇的最短时间是多少. 思路:首先可肯定最终相遇位置必定在区间$[0,max(x_i)]$中,二分最终位置,判断左右部分各自所 ...

  3. CodeForces 782B The Meeting Place Cannot Be Changed (二分)

    题意:题意:给出n个人的在x轴的位置和最大速度,求n个人相遇的最短时间. 析:二分时间,然后求并集,注意精度,不然会超时. 代码如下: #pragma comment(linker, "/S ...

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

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

  5. 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 ...

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

                                                                   B. The Meeting Place Cannot Be Change ...

  7. CodeForces - 782B The Meeting Place Cannot Be Changed(精度二分)

    题意:在一维坐标轴上,给定n个点的坐标以及他们的最大移动速度,问他们能聚到某一点处的最短时间. 分析: 1.二分枚举最短时间即可. 2.通过检查当前时间下,各点的最大移动范围之间是否有交集,不断缩小搜 ...

  8. codeforces 782B - The Meeting Place Cannot Be Changed

    time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standa ...

  9. 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 ...

随机推荐

  1. mysql数据类型和java对应表(copy)

    [说明] 资料来自:http://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-type-conversions.html My ...

  2. Unity资源的查找

    Object.Destroy static function Destroy(obj: Object, t: float = 0.0F): void;   Description Removes a ...

  3. 微信小程序-wepy-组件模板重复渲染

    微信小程序开发,有使用wepy框架的需求.上手: 安装自己可以到官网查看,飞机票:https://tencent.github.io/wepy/document.html#/ 具体开发模式和Vue开发 ...

  4. GoAhead4.1.0 开发总结二(自定义使用)

    环境 官方文档:https://www.embedthis.com/goahead/doc/ 源码下载: goahead-4.1.0-src.tgz 系统平台:Ubuntu 12.04.4 gcc v ...

  5. 乐搏讲自动化测试- Python环境搭建(7)

    Python的下载和安装 Python可应用于多平台包括 Linux 和 Mac OS X.你可以通过终端窗口输入 "python" 命令来查看本地是否已经安装Python以及Py ...

  6. http升级https(转)

    让你的网站免费支持 HTTPS 及 Nginx 平滑升级 为什么要使用 HTTPS ? 首先来说一下 HTTP 与 HTTPS 协议的区别吧,他们的根本区别就是 HTTPS 在 HTTP 协议的基础上 ...

  7. ASP.NET MVC5 之 客户端实现文件的下载

    MVC 实现下载功能主要借助于 File 属性: //下载文件接口 public ActionResult GetTrackTempIsc(ICSModels icsModels) { bool fl ...

  8. [Offer收割]编程练习赛84 -- 括号序列

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个只包含'(', ')'和''的字符串S,现在小Hi可以任意指定''为'('或')',不同的'*'可以是不同的字符. ...

  9. 每天学点Linux命令:倒叙打印文件第二行的前100个大写字母

    sed -n | rev 处理第二行             grep:提取大写字母   o: 不显示非结果  tr:删除换行   Cut:截取1-100个字符  rev:逆序 断断续续搞了好长时间. ...

  10. 232 Implement Queue using Stacks 用栈来实现队列

    使用栈来实现队列的如下操作: push(x) -- 将一个元素放入队列的尾部.pop() -- 从队列首部移除元素.peek() -- 返回队列首部的元素.empty() -- 返回队列是否为空.注意 ...