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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;


int main()
{
    int n, t;
    cin >> n;
    bool b[2] = {0, 0};
    int s = 0;
    for(int i = 0; i < n; i++){
        cin >> t;
        b[t] = 1;
        if(b[0] && b[1])
            s++, b[0] = b[1] = 0;
    }
    cout << s;
    return 0;
}
Copy
Tha Bits princ_iple
GNU G++17
12 ms
784 KB
Accepted