Cod sursa(job #1031456)

Utilizator lorundlorund lorund Data 15 noiembrie 2013 17:57:36
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.71 kb
#define LINES 276997
#include <cstdio>
#include <algorithm>



long long v[280000], N;

bool search(){
    int li=0, ls=LINES-1, m=ls/2;

    while (li<=ls){
        if (v[m]==N)
            return 1;
        else if (v[m]<N){
            li=m+1;
        }
        else{
            ls=m-1;
        }
        m=(li+ls)/2;
    }
    return 0;
}

int main()
{
    freopen("dtcsu.in", "r", stdin);
    freopen("dtcsu.out", "w", stdout);
    int Q, c=0;

    for (int i=0; i<LINES ; ++i){
        scanf("%lld", &v[i]);
    }
    std::sort(v, v+LINES);
    scanf("%d", &Q);
    for (int i=0; i<Q; ++i){
        scanf("%lld", &N);
        c+=search();
    }
    printf("%d", c);
    return 0;
}