結果

問題 No.275 中央値を求めよ
ユーザー mahnamahna
提出日時 2020-05-16 22:43:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 358 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 11,840 KB
実行使用メモリ 10,244 KB
最終ジャッジ日時 2023-10-24 04:36:30
合計ジャッジ時間 3,045 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,100 KB
testcase_01 AC 32 ms
10,100 KB
testcase_02 AC 30 ms
10,104 KB
testcase_03 RE -
testcase_04 AC 27 ms
10,100 KB
testcase_05 AC 28 ms
10,100 KB
testcase_06 AC 28 ms
10,104 KB
testcase_07 AC 28 ms
10,152 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 29 ms
10,112 KB
testcase_11 RE -
testcase_12 AC 29 ms
10,100 KB
testcase_13 RE -
testcase_14 AC 28 ms
10,100 KB
testcase_15 AC 28 ms
10,204 KB
testcase_16 AC 28 ms
10,216 KB
testcase_17 AC 29 ms
10,204 KB
testcase_18 AC 28 ms
10,128 KB
testcase_19 RE -
testcase_20 AC 28 ms
10,164 KB
testcase_21 AC 28 ms
10,132 KB
testcase_22 AC 28 ms
10,180 KB
testcase_23 RE -
testcase_24 AC 27 ms
10,116 KB
testcase_25 AC 27 ms
10,192 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 28 ms
10,180 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 28 ms
10,112 KB
testcase_38 AC 29 ms
10,116 KB
testcase_39 RE -
testcase_40 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8

ct = int(input().strip())
num = [int(x) for x in input().strip().split()]

num.sort()
last_key = len(num) - 1

if len(num) % 2 == 1:
    med_key = last_key / 2
    print(num[med_key])
else:
    med_key_before = last_key // 2
    med_key_after = med_key_before + 1
    
    ans = (num[med_key_before] + num[med_key_after]) / 2
    print(ans)
0