結果

問題 No.275 中央値を求めよ
ユーザー zenryoku_foool
提出日時 2017-06-27 14:35:09
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 157 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-10-04 11:31:29
合計ジャッジ時間 4,471 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 9 WA * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n = gets.to_i
a = gets.split.map(&:to_i)

A = a.sort.length

if A % 2 == 0 then
    puts (a[A / 2] + a[A / 2 - 1]) / 2.to_f
else 
    puts a[(A - 1) / 2]
end
0