Source Code
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;

int n;
int a[N];

int main()
{
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    cin >> n;
    int x = -1;
    int ans = 0;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> a[i];
        if(x == -1)
            x = a[i];
        else if (x != a[i])
        {
            ans++;
            x = -1;
        }
    }
    cout << ans << '\n';
}
Copy
Tha Bits EsmaelSufe
GNU G++17
6 ms
1.2 MB
Accepted