問題一覧 > 通常問題

No.275 Find the Median

レベル : / AI推定難易度 : 124 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $0$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 1321
作問者 : yuki2006
お気に入りにしたユーザー ProblemId : 746 / 自分の提出
問題文最終更新日: 2026-06-25 01:42:22
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 120 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。