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

Solution:Hash Function
Posted by Destiny 2 Nov 2002 10:21
program sofs2;
const
 maxn=70000;
var
 e:array[-maxn..maxn]of boolean;
 a:array[1..50000]of integer;
 n:integer;
procedure init;
var
 i,x,m:integer;
begin
 fillchar(e,sizeof(e),false);
 readln(n);
 for i:=1 to n do
  readln(a[i]);
 readln(m);
 for i:=1 to m do
  begin
   readln(x);
   e[x]:=true;
  end;
end;
procedure solve;
var
 i:integer;
begin
 for i:=1 to n do
  if e[10000-a[i]] then
   begin
    writeln('YES');
    halt;
   end;
 writeln('NO');
end;
begin
 init;
 solve;
end.
The solution above got AC
Posted by Destiny 2 Nov 2002 10:21
> program sofs2;
> const
>  maxn=70000;
> var
>  e:array[-maxn..maxn]of boolean;
>  a:array[1..50000]of integer;
>  n:integer;
> procedure init;
> var
>  i,x,m:integer;
> begin
>  fillchar(e,sizeof(e),false);
>  readln(n);
>  for i:=1 to n do
>   readln(a[i]);
>  readln(m);
>  for i:=1 to m do
>   begin
>    readln(x);
>    e[x]:=true;
>   end;
> end;
> procedure solve;
> var
>  i:integer;
> begin
>  for i:=1 to n do
>   if e[10000-a[i]] then
>    begin
>     writeln('YES');
>     halt;
>    end;
>  writeln('NO');
> end;
> begin
>  init;
>  solve;
> end.