zoukankan      html  css  js  c++  java
  • HDU多校-1004-Vacation(思维)

    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 nn cars in front of them. The iith car has a length of lili, the head of it is sisi from the stop-line, and its maximum velocity is vivi. The car Tom and Jerry are driving is l0l0 in length, and s0s0from the stop-line, with a maximum velocity of v0v0. 
    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 (1n105,n2×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 (1si,vi,li1091≤si,vi,li≤109). It's guaranteed that sisi+1+li+1,i[0,n1]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 10610−6. 
    Formally, let your answer be aa, and the jury's answer is bb. Your answer is considered correct if |ab|max(1,|b|)106|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
    ",ans);
       }
       return 0;
    }
  • 相关阅读:
    zstack(一)运行及开发环境搭建及说明(转载)
    ZStack深度试用:部署、架构与网络及其与OpenStack的对比
    saltops 安装及相关环境安装
    windows下安装rabbitmq的步骤详解
    SQLServer就更新并发处理的解决方案及测试!
    mysql 8.0.20安装教程,mysql详细安装教程
    .NET中的简单的并行
    四、VSCode调试vue项目
    三、使用VSCode配置简单的vue项目
    二、windows下搭建vue开发环境+IIS部署
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/11228919.html
Copyright © 2011-2022 走看看