Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created July 5, 2018 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/f11310780158758c6133fa90aab2f411 to your computer and use it in GitHub Desktop.
Save whatalnk/f11310780158758c6133fa90aab2f411 to your computer and use it in GitHub Desktop.
AtCoder ABC #102 C
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = (1..n).map{|i| a[i-1] - i}.sort
x = b[n/2]
puts b.map{|e| (e - x).abs}.inject(:+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment