Cod sursa(job #749501)
Utilizator | Data | 17 mai 2012 14:44:50 | |
---|---|---|---|
Problema | Xor Max | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 2.01 kb |
Program p1;
var a,c1,c2,poz,i,j1,j2,n,max,s,r:longint;
bufi,bufa:array[0..1 shl 23] of char;
x,y,sum:array[0..100000] of longint;
begin
assign(input,'xormax.in'); reset(input);
assign(output,'xormax.out'); rewrite(output);
settextbuf(input,bufi); settextbuf(output,bufa);
readln(n); read(a); s:=a; j1:=1; j2:=1; c1:=s; c2:=s; max:=0;
for i:=2 to n do begin
read(a);
if (c1 xor a)>=a then c2:=c1 xor a
else begin c2:=a; j1:=i; end;
if c2>=s then begin
if c2>max then begin
max:=1;
s:=c2; j2:=i; poz:=j1;
x[max]:=poz;
y[max]:=j2;
sum[max]:=s;
end
else begin
max:=max+1;
x[max]:=poz;
y[max]:=j2;
sum[max]:=s;
end;
end;
c1:=c2;
end;
c1:=x[1];
c2:=y[1];
r:=y[1]-x[1];
for i:=1 to max do if (c2<y[i]) then begin j2:=y[i]; if (y[i]-x[i]<r) then begin
r:=y[i]-x[i];
poz:=x[i];
end;
end;
write(sum[max],' ',poz,' ',j2);
close(input); close(output);
end.