Cod sursa(job #1935926)

Utilizator eu3neuomManghiuc Teodor-Florin eu3neuom Data 22 martie 2017 19:00:26
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.98 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");

typedef long long int ll;

const int NMax = 276997;
const int BMax = 5e4 + 5;

int pos = NMax - 1;
char Buffer[BMax];
inline void Read(ll &x) {
    while(!isdigit(Buffer[pos])) {
        if(++pos == BMax) {
            pos = 0;
            fin.read(Buffer, sizeof(Buffer));
        }
    }
    x = 0;
    while(isdigit(Buffer[pos])) {
        x = x * 10 + (Buffer[pos] - '0');
        if(++pos == BMax) {
            pos = 0;
            fin.read(Buffer, sizeof(Buffer));
        }
    }
}

int main(){
    ios::sync_with_stdio(false);

    unordered_set < ll > uSet;
    for(int i = 1; i <= NMax; i++) {
        ll x;
        Read(x);

        uSet.insert(x);
    }

    ll n;
    Read(n);

    int ans = 0;
    while(n--) {
        ll x;
        Read(x);

        if(uSet.find(x) != uSet.end()) ans++;
    }

    fout << ans;
    return 0;
}