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 is greater than 10. Age of each player must is within and 20. No two players can have the same age. There is a captain to each team. The communication gap between two players depends on their age difference, i.e. the communication gap are larger if the age difference is larger. Hence They select the captain of a team at such a way so this 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 the the team are provided. You are 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 would start with a integer N (1 < n <), number of team members followed by N space Separ Ated integers representing ages of the members of a. Each of these N integers is between (inclusive). Note to that, ages'll be given in strictly increasing the order or strictly. We are not mention which one are increasing and which one is decreasing, for have to be careful enough to handle both Ations.
Output
For each test case, output one line in the format ' case x:a ' (quotes for clarity), where x are the case number and a are th E 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 |
Complete code:
/*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;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/