#C8383. Median Age Calculator
Median Age Calculator
Median Age Calculator
You are given a list of ages. Your task is to compute the median age. First, sort the list in non-decreasing order. If there are an odd number of ages, the median is the middle element of the sorted list. If there are an even number of ages, the median is the average of the two middle elements.
In mathematical terms, let the sorted list be \(a_1, a_2, \dots, a_N\). Then the median is defined as follows:
- If \(N\) is odd, \(median = a_{\lceil N/2 \rceil}\).
- If \(N\) is even, \(median = \frac{a_{N/2} + a_{N/2+1}}{2}\).
Note that the answer should always be printed in a floating point format with one decimal place.
inputFormat
The input is read from standard input (stdin) and has the following format:
N a1 a2 ... aN
where \(N\) is an integer representing the number of ages and the second line contains \(N\) integer values separated by spaces.
outputFormat
Output a single number representing the median age in a floating-point format with exactly one digit after the decimal point (e.g., 10.0, 22.5).
## sample1
10
10.0