Source Code
#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define x first
#define y second
#define sz(u) (int)(u.size())
#define ld long double
#define all(u) u.begin(),u.end()

using namespace std;


int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	int prev=-1;
	int ans=0;
	for(int i=0;i<n;i++){
		if(prev==-1){
			cin>>prev;
		}
		else{
			int gt; cin>>gt;
			if(gt!=prev){
				prev=-1;
				ans++;
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}
Copy
Tha Bits medk
GNU G++17
5 ms
932 KB
Accepted