|
|
вернуться в форумSolution:Hash Function 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 > 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. |
|
|