No.275 Find the Median
タグ : / 解いたユーザー数 1321
作問者 :
Problem Statement
Given $N$ integers $Ai$, find their median.
The median is the value located at the center when the values are arranged in ascending order.
If the number of data values is even, take the arithmetic mean (the so-called ordinary average) of the two values closest to the center.
(Quoted from Wikipedia)
Median: Wikipedia
Find the answer to the first decimal place.
(As long as the value is correct, the output may contain decimal digits of 0.)
Input
$N$
$A_1\ A_2\ \dots\ A_{N}$
All inputs are given as integers.
- $1\le N \le 1000$
- $-1000\le A_i \le 1000$
Output
Find the median of the array.
Print a newline at the end.
Sample
Sample 1
Input
3 5 3 4
Output
4
The median in this case is $4$.
An output such as $4.00$ is also acceptable.
Sample 2
Input
4 1 9 8 4
Output
6
In this case, it is $(8+4)/2=6$.
Sample 3
Input
6 1 2 3 4 5 6
Output
3.5
In this case, the answer is a decimal.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。