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

I got AC,using hash list
Posted by ufx 3 Apr 2003 07:54
here is my program,please check it.
program ex;
const maxn=32767;
var   f:array[-32768..32767] of boolean;
      n1,n2,i,x,y:longint;
      flag:boolean;
begin
    readln(n1);
    fillchar(f,sizeof(f),0);
    for i:=1 to n1 do begin
        readln(x);
        f[x]:=true;
    end;
    readln(n2);
    flag:=false;
    for i:=1 to n2 do begin
        readln(x);
        y:=10000-x;
        if (y>=-32768) and (y<=32767) then
         if f[y] then begin
             flag:=true;
             break;
        end;
    end;
    if flag then writeln('YES')
    else writeln('NO');
end.