Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created July 17, 2018 02:09
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/797e167fecf15e5a8a2d1f7353530cc4 to your computer and use it in GitHub Desktop.
Save whatalnk/797e167fecf15e5a8a2d1f7353530cc4 to your computer and use it in GitHub Desktop.
AtCoder AGC #026 A
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
prev = a[0]
ans = 0
l = 1
(n - 1).times do |i|
if a[i + 1] == prev
l += 1
else
ans += (l / 2)
l = 1
end
prev = a[i + 1]
end
ans += (l / 2)
puts ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment