三分显然,要注意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;
}

最新文章

  1. C#调用C++代码遇到的问题总结
  2. WAF攻防研究之四个层次Bypass WAF
  3. 关于node.js和npm,cnpm的安装记录以及gulp自动构建工具的使用
  4. ruby -- 进阶学习(八)自定义方法route配置
  5. make命令--基础
  6. java反射工具类
  7. DCEF3 相关资料
  8. 数据结构(线段树):SPOJ GSS3 - Can you answer these queries III
  9. 【J2SE】java实现简单照片查看器
  10. http://www.spasvo.com/ceshi/open/kyxncsgj/Jmeter/
  11. ubuntu16.04编译安装mysql-boost-5.7.21并编译成php扩展测试与使用
  12. SQLite 语法(http://www.w3cschool.cc/sqlite/sqlite-syntax.html)
  13. ImCash:币安下架BSV之辩:规则、中立与去中心化
  14. 【redis】-- springboot集成redis及使用
  15. 使用iscroll,无法正常滑动的原因
  16. delphi 字符串string转流TStream
  17. SpringMVC环境搭建和详解
  18. AtomicReference,AtomicStampedReference与AtomicMarkableReference的区别
  19. LeetCode 43 Multiply Strings(字符串相乘)
  20. 关于MVC 上传文件

热门文章

  1. git使用笔记(三)文件忽略
  2. 用npm安装express时报proxy的错误的解决方法
  3. bzoj 4880 [Lydsy1705月赛]排名的战争 贪心
  4. 线程 ManualResetEvent 类
  5. spring+jersey+c3p0构建restful webservice(数据源采用c3p0)
  6. HDU1099---数学 | 思维
  7. php中的split函数
  8. bzoj 1996 DP
  9. 上传代码到github上
  10. algorithm ch2 Merge_sort