CodeForces
来源:互联网 发布:python股票预测算法 编辑:程序博客网 时间:2024/06/08 08:31
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const double INF = 1e9;const int maxn = 60000 + 10;double n, pos[maxn], v[maxn];bool check(double t) { double a = pos[0] - v[0] * t, b = pos[0] + v[0] * t; for (int i = 1; i < n; i++) { double x = pos[i] - v[i] * t; double y = pos[i] + v[i] * t; if (x > b || y < a) return false; if (a < x) a = x; if (b > y) b = y; } return true;}int main(){ while (scanf("%lf", &n) == 1) { for (int i = 0; i < n; i++) scanf("%lf", &pos[i]); for (int i = 0; i < n; i++) scanf("%lf", &v[i]); double l = 0, r = INF, t, ans = 0; while (r - l > 1e-7) { t = (l + r) / 2.0; if (check(t)) { r = t; ans = t; } else { l = t; } } printf("%lf\n", ans); } return 0;}
阅读全文
1 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- 数组中出现次数超过一半的数字
- 浅谈Three.js源码-render之WebGLCapabilities.js
- Hadoop集群完全分布式模式环境部署
- InteliJ IDEA
- 迷茫的新人
- CodeForces
- Linux
- 数字在排序数组中出现的次数
- 最大子列和问题(分治思想)
- 搭建一个简单的Go Web服务器
- Java研发方向如何准备BAT技术面试(超级干货)
- MySQL
- Android Ping
- 最小度限制生成树 POJ1639