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 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.

InputThis problem contains multiple test cases. 
For each test case, the first line contains an integer |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+5;
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=1;t<=n+1;t++)
       {
           scanf("%lf",&L[t]);
           sum[t]=sum[t-1]+L[t];
    }
    for(int t=1;t<=n+1;t++)
    {
        scanf("%lf",&S[t]); 
    }
    for(int t=1;t<=n+1;t++)
    {
        scanf("%lf",&V[t]);
    }
    double ans=0;
    for(int t=1;t<=n+1;t++)
    {
        ans=max(ans,(S[t]+sum[t]-L[1])/V[t]);
    }
    printf("%.10f\n",ans);
   }
   return 0;
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-01-25
猜你喜欢
  • 2019-07-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案