Source Code
#include <bits/stdc++.h>
#define ll  long long
#define ss second
#define ff first
#define sz size()
#define el '\n'
#define tc ll tt; cin>>tt; while(tt--)
using namespace std;

void fastIO() {
	ios::sync_with_stdio(false);
	cout.tie(nullptr);
	cin.tie(nullptr);
}

const ll N = 2e5 + 5;
bool d[N];

int main(){
    fastIO();
    ll n, d, ans = 0,res = 0,e = 0,s = 0;
    cin >> n >> d;
    vector<ll> v(n);
    for (int i = 0;i < n;i++){
        cin >> v[i];
        ll k = (v[i] & d);
        if (v[i] == d){
            res++;
            if (res % 2) ans = max(ans, res);
            else ans = max(ans, res - 1);
        }
        else {
            res = 0;
        }
    }
    cout << ans << el;
}
Copy
Legendary heba.daraghmeh
GNU G++17
2 ms
780 KB
Wrong Answer