#C11468. Find Median Scores

    ID: 40787 Type: Default 1000ms 256MiB

Find Median Scores

Find Median Scores

You are given a series of test cases. In each test case, the first number represents the number of student scores, followed by that many scores. Your task is to compute the median score for each test case. The scores should first be sorted in non-decreasing order. If the number of scores N is odd, the median is the element at index \(\lfloor N/2 \rfloor\). If N is even, the median is defined as the floor of the average of the two middle elements, i.e. \(\left\lfloor \frac{a_{N/2} + a_{N/2+1}}{2} \right\rfloor\).

Note: All arithmetic involving division should use integer division (i.e. floor division).

inputFormat

The input is read from stdin and has the following format:

  • The first line contains a single integer T representing the number of test cases.
  • The following T lines each contain a test case. Each test case starts with an integer N (the number of scores), followed by N integers representing the scores.

outputFormat

For each test case, output a single line containing the median score. The output should be written to stdout.

## sample
3
5 50 20 70 40 80
4 10 20 30 40
3 15 10 20
50

25 15

</p>