Vacation

Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1060 Accepted Submission(s): 420
Special Judge

Problem Description
Tom and Jerry are going on a vacation. They are now driving on a one-way road and several cars are in front of them. To be more specific, there are n cars in front of them. The ith car has a length of li, the head of it is si from the stop-line, and its maximum velocity is vi. The car Tom and Jerry are driving is l0 in length, and s0 from the stop-line, with a maximum velocity of v0.
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 0.
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.

Input
This problem contains multiple test cases.
For each test case, the first line contains an integer n (1≤n≤105,∑n≤2×106), the number of cars.
The next three lines each contains n+1 integers, li,si,vi (1≤si,vi,li≤109). It’s guaranteed that si≥si+1+li+1,∀i∈[0,n−1]

Output
For each test case, output one line containing the answer. Your answer will be accepted if its absolute or relative error does not exceed 10−6.
Formally, let your answer be a, and the jury’s answer is b. Your answer is considered correct if |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


题意:
Tom和Jerry的车是0号车
Tom和Jerry的车前面还有n辆车
每一辆车都有它的车身长度HDU 6581 Vacation——————2019多校第一场,思维_java,距离终点的距离HDU 6581 Vacation——————2019多校第一场,思维_ios_02,车的速度HDU 6581 Vacation——————2019多校第一场,思维_#include_03

这条路是单车道,后面的车不能超过前面的车
后面的车如果贴到了前面的车尾上,那么就会和前面的车以共同的速度前行

问0号车通过终点需要花费的时间
问0号车通过终点是指0号车车头通过终点

思维:

当0号车通过终点的时候,它的前面肯定有HDU 6581 Vacation——————2019多校第一场,思维_java_04辆车
当0号车通过终点的时候,如果它的前面有0辆车和它贴着,那么它的通过时间就是HDU 6581 Vacation——————2019多校第一场,思维_java_05
当0号车通过终点的时候,如果它的前面有1辆车和它贴着,那么它的通过时间就是HDU 6581 Vacation——————2019多校第一场,思维_ios_06

因为1号车前面没有车和它紧贴着,所以1号车通过终点的时间是HDU 6581 Vacation——————2019多校第一场,思维_#include_07,而在1号车通过终点后,0号车也要通过终点,此时它的速度也是HDU 6581 Vacation——————2019多校第一场,思维_#include_08,它要以HDU 6581 Vacation——————2019多校第一场,思维_#include_08的速度通过HDU 6581 Vacation——————2019多校第一场,思维_#include_10的距离,所以0号车通过终点的时间是HDU 6581 Vacation——————2019多校第一场,思维_java_11

当0号车通过终点的时候,如果它的前面有2辆车和它贴着,那么它的通过时间就是HDU 6581 Vacation——————2019多校第一场,思维_java_12

HDU 6581 Vacation——————2019多校第一场,思维_ios_13

我们只需要找出通过实践最大的那个就好了

//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#include<vector>


using namespace std;
typedef long long ll;
typedef pair<int ,int> P;

const int INF = 0x3f3f3f3f;
const int MAXN = 2e5+7;
double l[MAXN], s[MAXN], v[MAXN];

double Max(double a,double b){
return a>b?a:b;
}

int main(){
// freopen("../in.txt","r",stdin);
// freopen("../out.txt","w",stdout);

int n;
while(~scanf("%d",&n)){
n++;
for(int i=0;i<n;++i)
scanf("%lf",&l[i]);
for(int i=0;i<n;++i)
scanf("%lf",&s[i]);
for(int i=0;i<n;++i)
scanf("%lf",&v[i]);
double ans = -1.0;
double len = 0.0;
for(int i=0;i<n;++i){
if(i>0) len += l[i];
ans = Max(ans, (len+s[i])/v[i]);
// cout<<len<<" "<<len+s[i]<<" "<<v[i]<<" "<<ans<<endl;
}
printf("%.10lf\n", ans);
}
return 0;
}