UVa 11799 - Horror Dash

5 篇文章 0 订阅

Source: UVa OJ

It is that time of the year again! Colorful balloons and brightly colored banners 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 in their lives, students from the school try their hands at being the best clown ever. Some walk on long poles, others try to keep a crowd laughing for the day with stage comedy, while others still try out their first juggling act - some 'master clowns' even teach these juggling tricks to  visitors at the festival.

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

Input

The first line of input contains a single integer T (T≤50), the number of test cases. This line is followed by T input cases. Each input case is on a single line of space-separated integers. The first of these integers is N, the number of students acting as scary creatures. The rest of the line has N more integers, c0c1, ..., cn, 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 the track.

Output

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

Analysis

This problem is simply asking you to output the greatest integer in each set of test case. Trivial, isn't it?


#include <iostream>
using namespace std;

int main()
{
	int T; // number of test cases
	int N; // number of scary creatures
	int c; // to store speed of creatures
	int s; // speed of crown = speed of creature with highest speed

	cin >> T;
	for( int i=1; i<=T; i++ )
	{
		s=0; // clear the speed for each test case
		cin >> N;
		for( int j=0; j<N; j++ )
		{
			cin >> c;
			if( c>s ) s=c;
		}
		cout << "Case " << i <<": " << s << endl;
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值