HDU多校-1004-Vacation(思维)
The traffic light has a very long cycle. You can assume that it is always green light. However, since the road is too narrow, no car can get ahead of other cars. Even if your speed can be greater than the car in front of you, you still can only drive at the same speed as the anterior car. But when not affected by the car ahead, the driver will drive at the maximum speed. You can assume that every driver here is very good at driving, so that the distance of adjacent cars can be kept to be 00.
Though Tom and Jerry know that they can pass the stop-line during green light, they still want to know the minimum time they need to pass the stop-line. We say a car passes the stop-line once the head of the car passes it.
Please notice that even after a car passes the stop-line, it still runs on the road, and cannot be overtaken.
InputThis problem contains multiple test cases.
For each test case, the first line contains an integer nn (1≤n≤105,∑n≤2×1061≤n≤105,∑n≤2×106), the number of cars.
The next three lines each contains n+1n+1 integers, li,si,vili,si,vi (1≤si,vi,li≤1091≤si,vi,li≤109). It's guaranteed that si≥si+1+li+1,∀i∈[0,n−1]si≥si+1+li+1,∀i∈[0,n−1]OutputFor each test case, output one line containing the answer. Your answer will be accepted if its absolute or relative error does not exceed 10−610−6.
Formally, let your answer be aa, and the jury's answer is bb. Your answer is considered correct if |a−b|max(1,|b|)≤10−6|a−b|max(1,|b|)≤10−6.
The answer is guaranteed to exist.Sample Input
1
2 2
7 1
2 1
2
1 2 2
10 7 1
6 2 1
Sample Output
3.5000000000
5.0000000000 思路参考博客:https://blog.csdn.net/mmk27_word/article/details/96896277 代码:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#include<cmath>
const int maxn=1e5+;
typedef long long ll;
using namespace std;
double S[maxn],V[maxn],L[maxn],sum[maxn];
int main()
{
int n;
while(cin>>n)
{
for(int t=;t<=n+;t++)
{
scanf("%lf",&L[t]);
sum[t]=sum[t-]+L[t];
}
for(int t=;t<=n+;t++)
{
scanf("%lf",&S[t]);
}
for(int t=;t<=n+;t++)
{
scanf("%lf",&V[t]);
}
double ans=;
for(int t=;t<=n+;t++)
{
ans=max(ans,(S[t]+sum[t]-L[])/V[t]);
}
printf("%.10f\n",ans);
}
return ;
}
HDU多校-1004-Vacation(思维)的更多相关文章
- hdu多校1004 Distinct Values
Distinct Values Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): ...
- 2018 HDU多校第四场赛后补题
2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...
- 2018 HDU多校第三场赛后补题
2018 HDU多校第三场赛后补题 从易到难来写吧,其中题意有些直接摘了Claris的,数据范围是就不标了. 如果需要可以去hdu题库里找.题号是6319 - 6331. L. Visual Cube ...
- 2015 HDU 多校联赛 5363 Key Set
2015 HDU 多校联赛 5363 Key Set 题目: http://acm.hdu.edu.cn/showproblem.php? pid=5363 依据前面给出的样例,得出求解公式 fn = ...
- 2015 HDU 多校联赛 5317 RGCDQ 筛法求解
2015 HDU 多校联赛 5317 RGCDQ 筛法求解 题目 http://acm.hdu.edu.cn/showproblem.php? pid=5317 本题的数据量非常大,測试样例多.数据 ...
- HDU 6187 Destroy Walls (思维,最大生成树)
HDU 6187 Destroy Walls (思维,最大生成树) Destroy Walls *Time Limit: 8000/4000 MS (Java/Others) Memory Limit ...
- [HDU多校]Ridiculous Netizens
[HDU多校]Ridiculous Netizens 点分治 分成两个部分:对某一点P,连通块经过P或不经过P. 经过P采用树形依赖背包 不经过P的部分递归计算 树型依赖背包 v点必须由其父亲u点转移 ...
- hdu多校第一场1004(hdu6581)Vacation 签到
题意:有n+1辆车,每辆车都有一定的长度,速度和距离终点的距离,第1-n辆车在前面依次排列,第0辆车在最后面.不允许超车,一旦后车追上前车,后车就减速,求第0辆车最快什么时候能到达终点? 思路:对于每 ...
- 2017多校第9场 HDU 6161 Big binary tree 思维,类似字典树
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6161 题意: 题目是给一棵完全二叉树,从上到下从左到右给每个节点标号,每个点有权值,初始权值为其标号, ...
随机推荐
- CI4框架应用五 - 加载视图
这节我们来看一下CI4框架中视图的加载, CI4中提供了几种方式加载视图. 1. 利用CI4框架提供的全局函数view(‘模板名’),如果需要传参数可以在第二个参数传一个数组 我们先修改一下之前定义的 ...
- Vue组件通信之子传父
子组件向父组件通信主要通过自定义事件实现. 这里我记录一个小例子来帮助自己记忆. 通过点击子组件的按钮去执行父组件的函数并使用子组件传来的数据. 子组件定义如下: <template id=&q ...
- Qt之先用了再说系列-定时器的用法
Qt 定时器是一个比好用的东西,在此就地简单记录一下使用的方式: 1.首先包含头文件 #include <QTimer> 2.具体用法有几种,我就写其中2种吧 1>执行一次 这种方式 ...
- win10 安装msys2 和 ruby
1.选择自己的版本 https://rubyinstaller.org/downloads/ Ruby+Devkit 2.5.1-2 (x64) Ruby+Devkit 2.5.1-2 (x86) 2 ...
- Homekit_DoHome_智能通断器
本款通断器适用于IOS和android系统用户,苹果用户可以非常方便的使用siri进行有效控制,android用户需要下载Dohome App进行操作,同时支持市面上主流的智能音箱进行控制. 对于an ...
- 运用sklearn进行主成分分析(PCA)代码实现
基于sklearn的主成分分析代码实现 一.前言及回顾 二.sklearn的PCA类介绍 三.分类结果区域可视化函数 四.10行代码完成葡萄酒数据集分类 五.完整代码 六.总结 基于sklearn的主 ...
- 解析Class文件之创建InstanceKlass对象
ClassFileParser::parseClassFile()方法会将解析Class文件的大部分结果保存到instanceKlass对象中.创建instanceKlass对象的代码如下: int ...
- 设置与查看Linux系统中的环境变量
大家好,我是良许. 大家都知道,在 Linux 系统中,有环境变量和 Shell 变量这两种变量. 环境变量是在程序及其子程序中全局可用的,常常用来储存像默认的文本编辑器或者浏览器,以及可执行文件的路 ...
- topic的相关操作
1.建立topic cd 进入kafka的安装根目录的bin目录下 执行:./kafka-topics.sh --zookeeper ip:port,ip:port,ip:port/kafka-tes ...
- Shell脚本之for循环语句的应用
在实际工作中,经常会遇到某项任务需要多次执行的情况,而每次执行时仅仅是处理的对象不一样,其他命令相同.这时候可以使用for循环语句,针对不同的取值重复执行相同的命令序列. for循环语句的语法结构: ...