結果

問題 No.275 中央値を求めよ
ユーザー kaktskakts
提出日時 2015-12-09 02:29:54
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-14 20:55:26
合計ジャッジ時間 2,572 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 18 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#No.275 http://yukicoder.me/problems/746
import math
n = int(input())
#入力値を昇順ソートする
numList = sorted(list(map(int, input().split())))

length = len(numList)
if length % 2 == 0:
    #偶数の場合は、中央に近い2値の平均
    print(math.floor(length / 2))
    print(math.ceil(length / 2))
    low = math.floor(length / 2) - 1
    high = low + 1
    mid = (numList[low] + numList[high]) / 2
else:
    #配列の中央の値を取得
    mid = (numList[math.ceil(length / 2) - 1])
print(mid)
0