結果

問題 No.838 Noelちゃんと星々3
ユーザー letrangerjpletrangerjp
提出日時 2019-06-14 22:35:04
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 265 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 20,352 KB
最終ジャッジ日時 2024-04-26 17:32:40
合計ジャッジ時間 4,188 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 86 ms
12,288 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 84 ms
12,160 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 86 ms
12,160 KB
testcase_17 AC 85 ms
12,160 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 83 ms
12,160 KB
testcase_21 AC 85 ms
12,288 KB
testcase_22 AC 85 ms
12,288 KB
testcase_23 AC 87 ms
12,160 KB
testcase_24 AC 86 ms
12,288 KB
testcase_25 AC 84 ms
12,160 KB
testcase_26 AC 86 ms
12,160 KB
testcase_27 AC 86 ms
12,160 KB
testcase_28 AC 91 ms
12,416 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
Y = gets.split.map &:to_i

Y.sort!

ans = 0
N.times{|i|
  l = i == 0 ? 1.0/0 : Y[i] - Y[i - 1]
  r = i == N - 1 ? 1.0/0 : Y[i] - Y[i + 1]
  if l.abs < r.abs
    Y[i] = Y[i - 1]
    ans += l.abs
  else
    Y[i] = Y[i + 1]
    ans += r.abs
  end
}
p ans
0