結果

問題 No.275 中央値を求めよ
ユーザー KamiKami
提出日時 2018-05-03 23:55:55
言語 Ruby
(3.4.1)
結果
AC  
実行時間 101 ms / 1,000 ms
コード長 218 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-06-25 01:17:53
合計ジャッジ時間 5,247 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - num
Syntax OK

ソースコード

diff #

num = gets.to_i
num_array = gets.split.map(&:to_f)

num_array.sort!

if num_array.length.odd?
	puts num_array[num_array.length/2]
else
	puts (num_array[num_array.length/2] + num_array[num_array.length/2 - 1]) / 2.0
end
0