Cod sursa(job #1035010)

Utilizator mvcl3Marian Iacob mvcl3 Data 18 noiembrie 2013 11:37:43
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 kb
#include <fstream>
#include <algorithm>
#define in "dtcsu.in"
#define out "dtcsu.out"
#define Max_Size 276997
#define LL long long

std :: ifstream f(in);
std :: ofstream g(out);

LL V[Max_Size + 4];
int Q;
char Buff[Max_Size + 4];

inline void Read_Data()
{
    for(int i = 1; i <= Max_Size; ++i)
    {
        f.getline(Buff, Max_Size);
        for(int j = 0; Buff[j]; ++j)    V[i] = V[i] * 10 + Buff[j] - '0';
    }
}

inline void Solve()
{
    LL x;
    int sol = 0;

    f >> Q;

    while(Q --)
    {
        f >> x;

        int pos = std :: lower_bound(V + 1, V + Max_Size + 1, x) - V - 1;

        if(pos <= Max_Size && pos >= 1 && V[pos] == x)   ++sol;
    }

    g << sol << '\n';
}

int main()
{
    Read_Data();
    Solve();

    g.close();
    return 0;
}