UVa 11875 Brick Game (water ver.)

11875 - Brick Game

Time limit: 1.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2986

There is a village in Bangladesh, where brick game is very popular. Brick game is a team game. Each team consists of odd number of players. Number of players must be greater than 1 but cannot be greater than 10. Age of each player must be within 11 and 20. No two players can have the same age. There is a captain for each team. The communication gap between two players depends on their age difference, i.e. the communication gap is larger if the age difference is larger. Hence they select the captain of a team in such a way so that the number of players in the team who are younger than that captain is equal to the number of players who are older than that captain.

Ages of all members of the team are provided. You have to determine the age of the captain.

Input

Input starts with an integer T (T ≤ 100), the number of test cases.

Each of the next T lines will start with an integer N (1 < N < 11), number of team members followed by N space separated integers representing ages of all of the members of a team. Each of these N integers will be between 11 and 20 (inclusive). Note that, ages will be given in strictly increasing order or strictly decreasing order. We will not mention which one is increasing and which one is decreasing, you have to be careful enough to handle both situations.

Output

For each test case, output one line in the format “Case x: a” (quotes for clarity), where x is the case number and a is the age of the captain.

 

Sample Input

Sample Output

2

5 19 17 16 14 12

5 12 14 16 17 18

Case 1: 16

Case 2: 16


完整代码:

/*0.015s*/

#include<cstdio>

int main()
{
	int t, n, p, ans, x;
	scanf("%d", &t);
	for (int i = 1; i <= t; ++i)
	{
		scanf("%d", &n);
		p = n >> 1;
		while (n--)
		{
			scanf("%d", &x);
			if (n == p)
				ans = x;
		}
		printf("Case %d: %d\n", i, ans);
	}
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值