ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1196. History Exam

please help wa2
Posted by benia 12 May 2009 15:56

var
m,n,i,j,k,s,l:integer;
A: array [1..15000] of LongInt;
B: array [1..1000000] of LongInt;

begin
s:=0;
readln(n);
        for i:=1 to n do readln(A[i]);
readln(m);
        for j:=1 to m do begin readln(B[j]);     end;
i :=  1;
j :=  n;
k := 1;
for l:=1 to m do
        begin
                while  (i <=j) do
                begin
                k := (i + j) div 2;
                if B[l] > A[k] then i := k + 1
                                else j := k -1;

                end;
                if A[k] = B[l]  then s:=s+1;



        end;


writeln();
writeln(s);
readln;
end.
Re: please help wa2
Posted by Sergey Lazarev (MSU TB) 13 May 2009 00:05
Try this test:
3
10
11
12
3
12
11
10
please help wa2
Posted by benia 13 May 2009 13:15
thanks
Re: please help wa2
Posted by Habib [ Tashkent U of IT ] 3 Aug 2017 09:06
result must be 3 or no :)
Sergey Lazarev (MSU TB) wrote 13 May 2009 00:05
Try this test:
3
10
11
12
3
12
11
10
Re: please help wa2
Posted by Znol 5 Dec 2019 13:33
In your program teacher's dates should not be the same.
But once you will fix this your program won't pass test 8 because of time limit.
You have to use binary search. And in binary search there can be the same teacher's dates.