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 1021. Sacrament of the Sum

Please say, what is wrong?:)
Posted by -{ElectroN}- 25 Oct 2009 18:52
Is's my program...

type
b=array [1..50000] of longint;
var
n,m:longint;
mas:b;
a:longint;
i,j:longint;
flag:boolean;

function binar_search(x:longint):boolean;
var
k:longint;
begin
 i:=1;
 j:=n;
  repeat
   k:=(i+j) div 2;
   if x+mas[k]<10000 then
    i:=k+1 else
     j:=k-1;
  until (mas[k]+x=10000) or (i>j);
  if mas[k]+x=10000 then
   binar_search:=true else
    binar_search:=false;
end;

begin
readln(n);
for i:=1 to n do
 readln(mas[i]);

readln(m);
for i:=1 to m do
 begin
  readln(a);
   if binar_search(a)=true then
    flag:=true;
 end;
 if flag=true then
  writeln('YES') else
   writeln('NO');

   readln;
end.