結果

問題 No.609 Noelちゃんと星々
ユーザー letrangerjpletrangerjp
提出日時 2017-12-09 00:30:05
言語 Ruby
(3.3.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 204 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 11,192 KB
実行使用メモリ 23,012 KB
最終ジャッジ日時 2023-08-19 23:18:33
合計ジャッジ時間 4,569 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
20,704 KB
testcase_01 AC 103 ms
18,008 KB
testcase_02 AC 98 ms
16,804 KB
testcase_03 AC 106 ms
17,772 KB
testcase_04 AC 91 ms
16,336 KB
testcase_05 AC 153 ms
22,188 KB
testcase_06 AC 138 ms
21,048 KB
testcase_07 AC 113 ms
18,872 KB
testcase_08 AC 86 ms
15,496 KB
testcase_09 AC 101 ms
17,452 KB
testcase_10 AC 120 ms
19,516 KB
testcase_11 AC 118 ms
19,396 KB
testcase_12 AC 128 ms
20,404 KB
testcase_13 AC 89 ms
15,988 KB
testcase_14 AC 82 ms
15,340 KB
testcase_15 AC 138 ms
21,368 KB
testcase_16 AC 158 ms
22,764 KB
testcase_17 AC 132 ms
20,712 KB
testcase_18 AC 99 ms
16,908 KB
testcase_19 AC 143 ms
21,272 KB
testcase_20 AC 158 ms
22,892 KB
testcase_21 AC 162 ms
22,836 KB
testcase_22 AC 160 ms
23,012 KB
testcase_23 AC 157 ms
22,936 KB
testcase_24 AC 154 ms
22,920 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