結果

問題 No.275 中央値を求めよ
ユーザー StarMatyan
提出日時 2018-07-19 23:47:20
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 1,000 ms
コード長 597 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-25 01:53:30
合計ジャッジ時間 2,585 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#関数
numcount = int(input());
numdata = input();
numbigdata = numdata.split(" ");
numbigintdata = [int(numcount) for numcount in numbigdata]
numsutidata = sorted(numbigintdata);
result = 0;
smallnum = int((numcount/2)-1);
bignum = int((numcount/2));
middlenum  = int((numcount+1)/2-1);


#処理
if numcount % 2 == 0:
    if int(numsutidata[smallnum]+numsutidata[bignum])%2 ==0:
	    result = int(int(numsutidata[smallnum]+numsutidata[bignum])/2);
    else:
        result = int(numsutidata[smallnum]+numsutidata[bignum])/2;
else:
	result = int(numsutidata[middlenum]);

#出力
print(result);
0