|
|
back to boardBinary search Posted by Max 7 Oct 2008 16:35 readln(N1); for I:=0 to N1-1 do readln(A1[I]); readln(N2); for I:=0 to N2-1 do readln(A2[I]); for I:=0 to N1 -1 do begin k:=10000-A1[I]; l:=0; u:=N2-1; m:=1; while ((m<=N2) and (m>0)) do begin m:=(l+u) div 2; if k < A2[m] then l:=m+1 else if k>A2[m] then u:=m-1 else begin write('YES'); halt; end; end; end; write('NO'); "Time limit exceeded" чем плох мой алгоритм? |
|
|