Source Code

#include <bits/stdc++.h> 

#define int   long long
#define f first
#define s second
#define pb push_back
#define endl "\n"
#define SORT(v) sort(begin(v), end(v))
#define np string::npos 
#define mnn *min_element
#define mxx *max_element
#define all(v) v.begin(),v.end()
using namespace std;

// struct CustomComparator {
//     bool operator()(const pair<int, int>& a, const pair<int, int>& b) const {
//         if (a.first != b.first) {
//             return a.first < b.first; // First non-decreasing
//         } else {
//             return a.second > b.second; // Second non-increasing
//         }
//     }
// };



int32_t main(){ ios::sync_with_stdio(false);cin.tie(0);
    
    int tt;
    tt=1;
    // cin >> tt;
    
    while(tt--){
    
    
    int n,d,x; cin>>n>>d;
    int ctr=0;
    for(int i=0;i<n;i++){
        cin>>x;
        if(x==d) ctr++;
    }
    if(ctr>0 && d==0) cout<<ctr<<endl;
    else if(ctr>0) cout<<1<<endl;
    else cout<<0<<endl;
    }
  
}








Copy
Legendary abk.z1
GNU G++17
6 ms
824 KB
Wrong Answer