Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void MOUST(){
    ios_base::sync_with_stdio(0);
           cin.tie(0);
}
int main(){
    MOUST();

    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;

}
Copy
Tha Bits call911kid
GNU G++17
11 ms
836 KB
Accepted