Created
July 17, 2018 02:09
-
-
Save whatalnk/797e167fecf15e5a8a2d1f7353530cc4 to your computer and use it in GitHub Desktop.
AtCoder AGC #026 A
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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