Cod sursa(job #3256472)

Utilizator tomavladnicolae@gmail.comTomavlad [email protected] Data 14 noiembrie 2024 17:45:36
Problema Dtcsu Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <bits/stdc++.h>
using namespace std;

/**

*/
ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");
long long a[277000];
int n;
int Cautbin(long long x)
{
    int mij,st,dr;
    st=1;
    dr=n;
    while(st<=dr)
    {
        mij=(st+dr)/2;
        if(a[mij]==x)
            return 1;
        else if(a[mij]<x)st=mij+1;
        else dr=mij-1;
    }
    return 0;
}
int main()
{
    int i,Q,cnt;
    long long x;
    n=276997;
    cnt=0;
    for(i=1;i<=n;i++)
    {
        fin>>x;
        a[i]=x;
    }
    sort(a+1,a+n+1);
    fin>>Q;
    while(Q--)
    {
        fin>>x;
        cnt+=Cautbin(x);
    }
    fout<<cnt<<'\n';
    return 0;
}