Cod sursa(job #3213341)

Utilizator TheEpicWipedCreaVlad Chirita Alexandru TheEpicWipedCrea Data 12 martie 2024 22:48:49
Problema Dtcsu Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.76 kb
#include <bits/stdc++.h>

using namespace std;
ifstream in  ("dtcsu.in");
ofstream out("dtcsu.out");

#define INF 276997

int v[INF+1];

bool CB(long long val){
    int st=1,dr=INF,mij;
    while(st<=dr){
        mij=(st+dr)/2;
        if(v[mij]<val){
            st=mij+1;
        }
        else if(v[mij]>val){
            dr=mij-1;
        }
        else if(v[mij]==val){
            return true;
        }
        else{
            return false;
        }
    }
    return false;
}

int main(){
    long long n,x;
    for(int i=1;i<=INF;i++){
        in>>v[i];
    }
    sort(v+1,v+INF+1);
    in>>n;
    int nr=0;
    for(int i=1;i<=n;i++){
        in>>x;
        if(CB(x)==true){
            nr++;
        }
    }
    out<<nr;
}