|  | 
|  | 
| back to board | var tech : array [1..15000] of longint;pupil: array [1..1000000] of longint;
 i,m,n,kol:longint;
 Procedure Find(k:longint);
 Var l,r:longint;
 begin
 l:=1;
 r:=m;
 while true do begin
 if k < pupil[(l+r) div 2] then
 begin
 if r=(l+r) div 2 then break;
 r:=(l+r) div 2;
 end
 else
 if k > pupil[(l+r) div 2] then
 begin
 if l=(l+r) div 2 then break;
 l:=(l+r) div 2;
 end
 else
 if k = pupil[(l+r) div 2] then begin inc(kol); l:=(l+r) div 2 + 1; end;
 end;
 end;
 
 Procedure Quick(l,r:longint);
 Var i,j,k,q:longint;
 begin
 i:=l; j:=r; k:=pupil[(l+r) div 2];
 repeat
 while pupil[i] < k do inc(i);
 while pupil[j] > k do dec(j);
 if i<=j then
 begin
 q:=pupil[i];
 pupil[i]:=pupil[j];
 pupil[j]:=q;
 inc(i);
 dec(j);
 end;
 until i>j;
 if r > i then Quick(i,r);
 if l < j then Quick(l,j);
 end;
 
 begin
 kol:=0;
 read(n);
 for i:=1 to n do read(tech[i]);
 read(m);
 for i:=1 to m do read(pupil[i]);
 Quick(1,m);
 for i:=1 to n do
 find(tech[i]);
 writeln(kol);
 end.
 | 
 | 
|