Pagini recente » Cod sursa (job #741823) | Cod sursa (job #2661999) | Cod sursa (job #3268509) | Cod sursa (job #604377) | Cod sursa (job #3209349)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");
long long a[280000];
int cautbin(long long x) {
int st = 1, dr = 276997;
while (st <= dr) {
int mij = (st + dr) / 2;
if (a[mij] == x)
return 1;
else if (a[mij] < x)
st = mij + 1;
else dr = mij - 1;
}
return -1;
}
int main()
{
int i, n, r, Q, cnt = 0, gasit;
long long x;
for (i = 1; i <= 276997; i++)
{
fin >> x;
a[i] = x;
}
sort(a + 1, a + 276998);
fin >> Q;
while (Q--)
{
fin >> x;
if (x > 0)
{
cnt += cautbin(x);
}
}
fout << cnt << "\n";
return 0;
}