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

using namespace std;
using ll = long long;

int main() {

    int n;
    cin >> n;
    vector<int> v(n);

    for(int i = 0; i < n; i++){
        cin >> v[i];
        v[i]++;
    }

    int ans = 0, sum = 0;
    for(int i = 0; i < n; i++){
        sum |= v[i];
        if(sum == 3){
            sum = 0;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}
Copy
Tha Bits أحمد الغضبان
GNU G++17
11 ms
1.2 MB
Accepted