結果

問題 No.275 中央値を求めよ
コンテスト
ユーザー iad_2889
提出日時 2019-04-30 08:30:58
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 21 ms / 1,000 ms
+ 328µs
コード長 357 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-10-08 09:00:52
合計ジャッジ時間 2,990 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
A = [int(x) for x in input().split()]
A.sort()
half_n = N // 2
center_value = -1
if N % 2:
    center_value = A[half_n]
else:
    c1,c2 = A[half_n - 1:half_n + 1]
    center_value = (c1 + c2) / 2
if center_value % 1:
    center_value = "{:.1f}".format(center_value)
else:
    center_value = "{:.0f}".format(center_value)
print(center_value)
0