const max = 10000000; var a,b:array[1..max] of longint; m,n:longint; procedure qs(l,h:longint); var x,i,j,t:longint; begin x:=b[(l+h) div 2]; i:=l;j:=h; repeat while b[i] < x do inc(i); while b[j] > x do dec(j); if i<=j then begin t:=b[i];b[i]:=b[j];b[j]:=t; inc(i);dec(j); end; until i>j; if L<j then qs(L,j); if i<H then qs(i,H); end; function search(x:longint):byte; var l,r,m:longint; begin l:=1;r:=n; repeat m:=(l+r) div 2; if b[m]=x then exit(1) else if b[m]>x then r:=m-1 else l:=m+1; until l>r; exit(0); end; procedure enter; var i:longint; begin readln(m, n); for i:=1 to m do readln(a[i]); for i:=1 to n do readln(b[i]); end; procedure solve; var d,i:longint; begin qs(1,n); d:=0; for i:=1 to m do inc(d,search(a[i])); writeln(d); end; BEGIN assign(input,'xuathien.inp');reset(input); assign(output,'xuathien.out');rewrite(output); enter; solve; close(input);close(output); END.
* Chuyên dạy lập trình ONLINE cho học sinh THCS, THPT *.
Mọi giao lưu, trao đổi, xin liên hệ: Lê Quang Vinh - zalo: 037.803.8755.
Page: Lớp học Code Sky
Group FB1: Ôn thi HSG9 - THTB - TS10 chuyên tin
Group FB2: Học Scratch - Ôn thi Tin học trẻ bảng A
Thứ Hai, 9 tháng 5, 2022
XUATHIEN PASCAL
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét
Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.