#C4547. Median Calculation for Participant Scores
Median Calculation for Participant Scores
Median Calculation for Participant Scores
You are given several test cases. In each test case, you have a number of participants. For each participant, a list of scores is provided. Your task is to compute the median of the scores for each participant.
The median is defined as follows:
If the sorted list has an odd number of elements, the median is the middle element. If the list has an even number of elements, the median is computed by the formula: \(\frac{a_{\frac{n}{2}} + a_{\frac{n}{2}+1}}{2}\), where \(a_i\) denotes the \(i^{th}\) smallest element (using 1-indexing).
Print the median for each participant on a separate line. Make sure to handle both integer and non-integer medians.
inputFormat
The input begins with an integer \(T\) representing the number of test cases. For each test case:
- The first line contains an integer \(P\) denoting the number of participants.
- Each of the next \(P\) lines starts with an integer \(G_i\) indicating the number of scores for the participant, followed by \(G_i\) space-separated integers representing the scores.
All input is provided via standard input (stdin).
outputFormat
For each participant, output the median of the scores on a new line. The output should be sent to standard output (stdout). If the median is not an integer, print it as a floating point number.
## sample2
3
3 10 30 20
4 15 45 10 25
2 100 200
2
1 50
5 90 80 70 60 50
20
20
150
50
70
</p>