結果
| 問題 |
No.609 Noelちゃんと星々
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2018-03-13 09:09:26 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 138 ms / 2,000 ms |
| コード長 | 237 bytes |
| コンパイル時間 | 275 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 20,992 KB |
| 最終ジャッジ日時 | 2024-11-17 21:39:12 |
| 合計ジャッジ時間 | 4,637 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
コンパイルメッセージ
Main.rb:1: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument Main.rb:6: warning: assigned but unused variable - n Syntax OK
ソースコード
def g (xs,m)
return xs.inject(0){|sum,e|
sum+(m-e).abs
}
end
n=gets.to_i
xs=gets.split.map{|e| e.to_i}.sort
if xs.size==1
puts 0
else
d1=g(xs,xs[xs.size/2])
d2=g(xs,xs[xs.size/2+1])
if(d1<d2)
puts d1
else
puts d2
end
end
horiesiniti