UVa 11875 Brick Game (Water ver.)

Source: Internet
Author: User
Tags time limit

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.