2017 ACM-ICPC ECL-FINAL c traffic light-贪心

gym101775-c 

http://codeforces.com/gym/101775/problem/C

出门时间不确定,求最坏情况的最小时间

设置off使得最短等待时间为0,可以得知,此时,最坏情况,最多等一个红绿灯(因为只要等过一个红绿灯,之后每次过红绿灯都不需要再等待),所以等待时间最大为max(bi)


#include <cstdio>

#include <iostream>

using namespace std;

const int maxn = 1000 + 5;


int main()

{

    int T;scanf("%d",&T);

    for (int cn = 1; cn <= T; cn ++) {

        int n;scanf("%d",&n);

        double ans = 0,t;

        for (int i = 0; i <= n; i ++) {

            scanf("%lf",&t);

            ans += t;

        }

        double maxb = 0;

        for (int i = 0; i < n; i ++) {

            scanf("%*lf%lf",&t);

            maxb = max(maxb,t);

        }

        printf("Case #%d: %.10lf\n",cn,ans + maxb);

    }

    return 0;

}

猜你喜欢

转载自blog.csdn.net/sm_545/article/details/80313462