Skip to content

Instantly share code, notes, and snippets.

@yaki29
Created July 24, 2018 11:18
Show Gist options
  • Save yaki29/407c51613fc44ae57f4990673093b97b to your computer and use it in GitHub Desktop.
Save yaki29/407c51613fc44ae57f4990673093b97b to your computer and use it in GitHub Desktop.
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