www.pudn.com > TJU.rar > ac1042.pas


program tju1042; 
const 
  maxn=10000; 
type 
  list=array[0..maxn]of longint; 
var 
  a,b:list; 
  t,u,n,i,x:longint; 
  ok:boolean; 
procedure qsort(var a:list;s,t:word); 
  var 
    p,i,j,tmp:longint; 
  begin 
    if s>=t then exit; 
    p:=s+random(t-s+1); 
    tmp:=a[p];a[p]:=a[s]; 
    i:=s;j:=t; 
    repeat 
      while (i=tmp) do dec(j); 
      if i=j then break;a[i]:=a[j];inc(i); 
      while (i0 then begin writeln('NO');continue;end; 
    qsort(a,1,n);qsort(b,1,n); 
    x:=a[1]-b[1];ok:=true; 
    for i:=2 to n do 
      if a[i]-b[i]<>x then begin 
        ok:=false;break; 
      end; 
    if ok then writeln('YES') else writeln('NO'); 
  end; 
end.