Created
July 24, 2018 11:18
-
-
Save yaki29/407c51613fc44ae57f4990673093b97b to your computer and use it in GitHub Desktop.
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
using namespace std; | |
#include<bits/stdc++.h> | |
int main() | |
{ | |
int n; | |
cin>>n; | |
int a[n+2]; | |
a[0] = a[n+1] = 0; | |
for(int i = 1; i<=n; i++) | |
cin>>a[i]; | |
int ans = 0; | |
for(int i = 1; i<=n; i+=2) | |
{ | |
if( (a[i] == a[i+1]) || (a[i] == a[i-1]) ) | |
ans++; | |
} | |
int cnt = 0; | |
for(int i = 2; i<=n; i+=2) | |
{ | |
if( (a[i] == a[i+1]) || (a[i] == a[i-1]) ) | |
{ | |
cnt++; | |
} | |
} | |
cout<<min(ans, cnt)<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment