|
|
back to boardplease 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 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 result must be 3 or no :) 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. |
|
|