Submission #3219936


Source Code Expand

n = gets.to_i
a = gets.split.map.with_index { |val, idx| val.to_i - (idx+1) }
b = a.sort[a.size/2]

ans = 0
a.each do |val|
  ans += (val - b).abs
end

puts ans

Submission Info

Submission Time
Task C - Linear Approximation
User OUDON
Language C++14 (GCC 5.4.1)
Score 0
Code Size 169 Byte
Status CE

Compile Error

./Main.cpp:1:1: error: ‘n’ does not name a type
 n = gets.to_i
 ^
./Main.cpp:3:1: error: ‘b’ does not name a type
 b = a.sort[a.size/2]
 ^