• the meaning of problems
Numbered 0 to n, n + 1 line have traffic lights vehicle, from 0 to n from the line closer traffic lights
Each will have a maximum speed v, body length l, and the distance from the line of traffic lights s,
A front reaches the line then the car has reached the line
If a car is not close to the front of the car, so the car can travel at a maximum speed
If the front next to a car, close to the front before a rear travel, can not overtake!
Even after the traffic light line can not overtake!
Asked the shortest time of the first 0 is offline farthest one, to reach the line
• ideas
Since I can not overtake, then there are two possibilities when the furthest car to the line
① own line to $ t = \ frac {s_ {0}} {v_ {0}} $
② connected to the car after the first line p $ \ frac {s_ {p} + \ sum_ {1} ^ {p} l_ {i}} {v_ {p}} $
Explain why this is so then counted in the back of a car
Suppose there are two cars $ a_ {1} $ velocity $ v $, $ a_ {0} $ speed 2V $ $
When the current vehicle reaches $ p $ surface points, while the back of the car to reach $ {p} '$, both the time spent on the same
Similarly seen
When $ a_ {1} $ O $ $ arrival point, $ a_ {0} $ reach $ l_ {1} $ point, i.e. $ a_ {0} $ distance from the finish line is $ a_ {1} $ of Car length
② even if the formula is in the first car behind the $ p $ ($ p $ behind the cars are all connected up)
When the first car to reach the finish line $ p $, the farthest distance from the car to the finish line is that all $ p $ car length behind the car - a car last longer own car
I.e. $ sum = \ sum_ {1} ^ {p} l_ {i} $
Therefore traveling time is $ p $ + vehicle traveling time to the furthest car $ v_ {p} $ $ SUM with time i.e. $ $ \ frac {s_ {p}} {v_ {p}} + \ frac {\ sum_ {1} ^ {p} l_ {i}} {v_ {p}} $
Since the ground behind the car uncertain, it is possible to calculate the maximum time,
Travel time is long explanation slow speed behind will certainly pick behind him
• Code
View Code1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn=1e6+6; 4 double l[maxn],s[maxn],v[maxn]; 5 double sum[maxn]; 6 int main() 7 { 8 int n; 9 while(~scanf("%d",&n)) 10 { 11 for(int i=0;i<=n;i++) 12 { 13 scanf("%lf",&l[i]); 14 if(i==0) 15 continue; 16 sum[i]=sum[i-1]+l[i]; 17 } 18 for(int i=0;i<=n;i++) 19 scanf("%lf",&s[i]); 20 for(int i=0;i<=n;i++) 21 scanf("%lf", & V [I]); 22 is 23 is /// alone across the finish 24 Double ANS = S [ 0 ] / V [ 0 ]; 25 26 is /// line through the end point 27 for ( int I = . 1 ; I <= n- ; I ++ ) 28 ANS = max (ANS, (S [I] + SUM [I]) / V [I]); 29 30 the printf ( " % .10f \ n- " , ANS); 31 is } 32 }