結果

問題 No.609 Noelちゃんと星々
ユーザー letrangerjpletrangerjp
提出日時 2017-12-09 00:30:05
言語 Ruby
(3.3.0)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 204 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 20,224 KB
最終ジャッジ日時 2024-05-07 06:20:07
合計ジャッジ時間 4,771 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
17,792 KB
testcase_01 AC 120 ms
14,976 KB
testcase_02 AC 110 ms
13,952 KB
testcase_03 AC 118 ms
14,592 KB
testcase_04 AC 103 ms
13,312 KB
testcase_05 AC 166 ms
19,840 KB
testcase_06 AC 161 ms
18,048 KB
testcase_07 AC 128 ms
15,872 KB
testcase_08 AC 98 ms
12,416 KB
testcase_09 AC 118 ms
14,080 KB
testcase_10 AC 147 ms
16,896 KB
testcase_11 AC 137 ms
16,256 KB
testcase_12 AC 154 ms
17,536 KB
testcase_13 AC 100 ms
12,672 KB
testcase_14 AC 97 ms
12,288 KB
testcase_15 AC 157 ms
18,176 KB
testcase_16 AC 168 ms
19,712 KB
testcase_17 AC 156 ms
17,920 KB
testcase_18 AC 108 ms
13,696 KB
testcase_19 AC 159 ms
18,048 KB
testcase_20 AC 171 ms
20,224 KB
testcase_21 AC 176 ms
20,224 KB
testcase_22 AC 172 ms
20,224 KB
testcase_23 AC 173 ms
20,224 KB
testcase_24 AC 173 ms
20,224 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map &:to_i
A.sort!
min = A[0]
A.map!{|a|a-min}
sum = A.sum
prev = A[0]
p A.map.with_index(0){|a,i|
  diff = a - prev
  prev = a
  sum += diff * i
  sum -= diff * (N - i)
}.min
0