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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n,a=0,b=0,c=0;cin>>n;
    int k[n];
    for(int i=0;i<n;i++){
        cin>>k[i];
        k[i]?a++:b++;
        if(a&&b)
            c++,b=a=0;
    }
    cout<<c;
    return 0;
}
Copy
Tha Bits Mohamedmaher
GNU G++17
9 ms
1.4 MB
Accepted