UVA11799 Horror Dash【求极值+水题】

It is that time of the year again! Colorful balloons and brightly coloredbanners spread out over your entire neighborhood for just this one occasion.It is the annual clown’s festival at your local school. For the first time intheir lives, students from the school try their hands at being the best clownever. Some walk on long poles, others try to keep a crowd laughing forthe day with stage comedy, while others still try out their first juggling act— some ‘master clowns’ even teach these juggling tricks to visitors at thefestival.

  As part of the festival, there is a unique event known as the “HorrorDash”. At this event, N (1 ≤ N ≤ 100) students dressed in the scariestcostumes possible start out in a race to catch a poor clown running onthe same track. The clown trips over, loses his mind, and does all sorts ofcomical acts all while being chased round and round on the track. To keepthe event running for as long as possible, the clown must run fast enough not to be caught by any ofthe scary creatures. However, to keep the audience on the edge of their seats, the clown must not runtoo fast either. This is where you are to help. Given the speed of every scary creature, you are to findout the minimum speed that the clown must maintain so as not to get caught even if they keep onrunning forever.

Input

The first line of input contains a single integer T (T ≤ 50), the number of test cases. This line isfollowed by T input cases. Each input case is on a single line of space-separated integers. The firstof these integers is N, the number of students acting as scary creatures. The rest of the line hasN more integers, c0, c1, . . . , cN−1, each representing the speed of a creature in meters per second(1 ≤ ci ≤ 10000 for each i). You can assume that they are always running in the same direction on thetrack.

Output

There should be a single line of output for each test case, formatted as ‘Case c: s’. Here, c representsthe serial number of the input case, starting with 1, while s represents the required speed of the clown,in meters per second.

Sample Input

2

5 9 3 5 2 6

1 2

Sample Output

Case 1: 9

Case 2: 2


问题链接UVA11799 Horror Dash

问题简述参见上文。

问题分析:这个问题就是一个求极值问题,看懂题意就没有问题了

程序说明:(略)

题记:(略)


参考链接:(略)


AC的C++语言程序如下:

/* UVA11799 Horror Dash */

#include <iostream>

using namespace std;

int main()
{
    int t, n, ci, maxc;

    cin >> t;
    for(int i=1; i<=t; i++) {
        cin >> n;

        maxc = -1;
        for(int j=1; j<=n; j++) {
            cin >> ci;
            if(ci > maxc)
                maxc = ci;
        }

        cout << "Case " << i << ": " << maxc << endl;
    }
    return 0;
}




posted on 2017-07-28 01:21  海岛Blog  阅读(167)  评论(0编辑  收藏  举报

导航