結果

問題 No.609 Noelちゃんと星々
ユーザー masaktmasakt
提出日時 2017-12-09 16:46:32
言語 Ruby
(3.3.0)
結果
AC  
実行時間 535 ms / 2,000 ms
コード長 175 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 20,224 KB
最終ジャッジ日時 2024-05-07 12:35:45
合計ジャッジ時間 10,657 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 423 ms
17,920 KB
testcase_01 AC 258 ms
14,976 KB
testcase_02 AC 206 ms
13,696 KB
testcase_03 AC 252 ms
14,592 KB
testcase_04 AC 177 ms
13,056 KB
testcase_05 AC 497 ms
19,840 KB
testcase_06 AC 440 ms
18,176 KB
testcase_07 AC 303 ms
15,872 KB
testcase_08 AC 137 ms
12,672 KB
testcase_09 AC 223 ms
14,080 KB
testcase_10 AC 351 ms
16,896 KB
testcase_11 AC 328 ms
16,256 KB
testcase_12 AC 397 ms
17,536 KB
testcase_13 AC 153 ms
12,928 KB
testcase_14 AC 120 ms
12,416 KB
testcase_15 AC 449 ms
18,176 KB
testcase_16 AC 510 ms
19,968 KB
testcase_17 AC 420 ms
17,664 KB
testcase_18 AC 203 ms
13,696 KB
testcase_19 AC 441 ms
18,176 KB
testcase_20 AC 519 ms
20,224 KB
testcase_21 AC 522 ms
19,968 KB
testcase_22 AC 535 ms
20,224 KB
testcase_23 AC 520 ms
20,224 KB
testcase_24 AC 524 ms
20,224 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
a=gets.split.map &:to_i
d=10**99
l=0
r=n-1
a.sort!
32.times{
  c=(l+r)/2
  t=a.reduce(0){|s,y|s+(y-a[c]).abs}
  if t<=d
    d=t
    r=c
  else
    l=c
  end
}
p d
0