Pagini recente » Cod sursa (job #43647) | Cod sursa (job #1689710) | Cod sursa (job #593339) | Cod sursa (job #289134) | Cod sursa (job #749498)
Cod sursa(job #749498)
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 (c1>x[i]) and (c2<y[i]) and (y[i]-x[i]<r) then begin poz:=x[i]; j2:=y[i]; r:=y[i]-x[i]; end;
write(sum[max],' ',poz,' ',j2);
close(input); close(output);
end.