Programming contests

Magas szintű programozási nyelvek 1, gyakorló feladatsor, 2015. április 24.

April 24, 2015 10:00 AM – April 24, 2015 10:00 AM

Brick Game

There is a village in Bangladesh, where brick game is very popular. Brick game is a team game. Each team consists of an odd number of players. The number of players must be greater than 1 but cannot be greater than 10. The age of each player must be between 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 the captain is equal to the number of players who are older than the captain.

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

Input Specification

The 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), the number of team members, followed by N space-separated integers representing the ages of all of the members of the team. Each of these N integers will be between 11 and 20 (inclusive). Note that the ages in one test case will be given in strictly increasing order or strictly decreasing order. It will not be mentioned which sequence is increasing and which one is decreasing, you have to be careful enough to handle both situations.

Output Specification

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

Sample Input

  1. 2
  2. 5 19 17 16 14 12
  3. 5 12 14 16 17 18
download as text file

Output for Sample Input

  1. Case 1: 16
  2. Case 2: 16
download as text file
University of Debrecen; Faculty of Informatics; v. 05/24/2018