Source Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const int inf = 1e9;
const ll infll = 1e18;
const int M = 1e9 + 7;
const int N = 4e5;

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for (int i = 0; i < n; ++i){
		scanf("%d", &a[i]);
	}
	int ans = 0, last;
	for (int i = 1; i < n; ++i){
		if(a[i] != a[i-1] && last != 1){
			++ans, last = 1;
			continue;
		}
		last = 0;
	}
	printf("%d\n", ans);
}	
Copy
Tha Bits Hambubger
GNU G++17
8 ms
1.2 MB
Accepted