Source Code
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,d;
    cin>>n>>d;
    vector<int> v(n);
    for(int i = 0 ;i < n ;i++)
     cin>>v[i];
    int cnt = 0,ans = 0;
    for(int i = 0 ; i < n; i++)
    {
        if(v[i] == d)
         cnt++;
        else
         cnt = 0;
        if(cnt&1 or d == 0)
        ans = max(cnt,ans);
    }
    cout<<ans;
}
Copy
Legendary moathhamudah
GNU G++17
4 ms
984 KB
Wrong Answer