链接: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();
}
}

最新文章

  1. VS 中關於附加到進程中調試 的問題。
  2. js保留位和取整
  3. osharp3引入事务后操作结果类别的调整
  4. windows 中 使用MongoDB
  5. 转载:奇异值分解(SVD) --- 线性变换几何意义(上)
  6. java递归简易应用教程
  7. [LeetCode] 147. Insertion Sort List 解题思路
  8. mysql分组查询前n条数据
  9. 用UltraISO制作CentOS U盘安装盘
  10. 前端日常常用git命令
  11. JS自学笔记02
  12. MySQL的show profile(已过时)简介以及该功能在MySQL 5.7中performance_schema中的替代
  13. Ionic App 启动时报Application Error - The connection to the server was unsuccessful
  14. python内置模块之unittest测试(五)
  15. EXCEL 将网络图片地址插入为锁定的图片单元格宏
  16. lua--clone
  17. JS数组的赋值
  18. Android MVP 构架封装
  19. SQLServer 跨库查询实现方法
  20. PouchDB:JavaScript同步数据库

热门文章

  1. 常用开源&lt;监控软件&gt;介绍
  2. POJ 2452 Sticks Problem (暴力或者rmq+二分)
  3. svg image 图片无法铺满 circle 的问题解决
  4. MySQL-ProxySQL中间件(二)| Admin Schemas介绍
  5. Springboot拦截器线上代码失效
  6. WMI 技术
  7. 暴力/思维 HDOJ 5386 Cover
  8. 转 linux shell自定义函数(定义、返回值、变量作用域)介绍
  9. mysql-installer-web-community-5.7.18.1.msi的安装(图文详解)
  10. Mysql动态查询