【三分】Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) B. The Meeting Place Cannot Be Changed
2024-10-04 11:17:13
三分显然,要注意EPS必须设成1e-6,设得再小一点都会TLE……坑炸了
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define EPS 0.000001
int n,x[60010],v[60010];
double calc(double p)
{
double res=0;
for(int i=1;i<=n;++i)
res=max(res,fabs(p-(double)x[i])/(double)v[i]);
return res;
}
int main()
{
// freopen("b.in","r",stdin);
scanf("%d",&n);
for(int i=1;i<=n;++i)
scanf("%d",&x[i]);
for(int i=1;i<=n;++i)
scanf("%d",&v[i]);
double l=1.0,r=1000000000.0;
while(r-l>EPS)
{
double m1=l+(r-l)/3.0;
double m2=r-(r-l)/3.0;
double t1=calc(m1),t2=calc(m2);
if(t1>t2)
l=m1;
else
r=m2;
}
printf("%.12lf\n",calc(l));
return 0;
}
最新文章
- C#调用C++代码遇到的问题总结
- WAF攻防研究之四个层次Bypass WAF
- 关于node.js和npm,cnpm的安装记录以及gulp自动构建工具的使用
- ruby -- 进阶学习(八)自定义方法route配置
- make命令--基础
- java反射工具类
- DCEF3 相关资料
- 数据结构(线段树):SPOJ GSS3 - Can you answer these queries III
- 【J2SE】java实现简单照片查看器
- http://www.spasvo.com/ceshi/open/kyxncsgj/Jmeter/
- ubuntu16.04编译安装mysql-boost-5.7.21并编译成php扩展测试与使用
- SQLite 语法(http://www.w3cschool.cc/sqlite/sqlite-syntax.html)
- ImCash:币安下架BSV之辩:规则、中立与去中心化
- 【redis】-- springboot集成redis及使用
- 使用iscroll,无法正常滑动的原因
- delphi 字符串string转流TStream
- SpringMVC环境搭建和详解
- AtomicReference,AtomicStampedReference与AtomicMarkableReference的区别
- LeetCode 43 Multiply Strings(字符串相乘)
- 关于MVC 上传文件