根据凸包的单峰性质,穷举第一个顶点
然后先更新第三个顶点,再更新第二个顶点

 var x,y,q:array[..] of longint;
ans,n,t,k,i,j:longint; function cross(i,j,k:longint):longint;
begin
exit((x[i]-x[k])*(y[j]-y[k])-(x[j]-x[k])*(y[i]-y[k]));
end; function max(a,b:longint):longint;
begin
if a>b then exit(a) else exit(b);
end;
procedure swap(var a,b:longint);
var c:longint;
begin
c:=a;
a:=b;
b:=c;
end; procedure sort(l,r: longint);
var i,j,p,q: longint;
begin
i:=l;
j:=r;
p:=x[(l+r) shr ];
q:=y[(l+r) shr ];
repeat
while (x[i]<p) or (x[i]=p) and (y[i]<q) do inc(i);
while (p<x[j]) or (p=x[j]) and (q<y[j]) do dec(j);
if not(i>j) then
begin
swap(x[i],x[j]);
swap(y[i],y[j]);
inc(i);
j:=j-;
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end; begin
readln(n);
while n<>- do
begin
for i:= to n do
readln(x[i],y[i]);
sort(,n);
q[]:=;
t:=;
for i:= to n do
begin
while (t>) and (cross(q[t],i,q[t-])<=) do dec(t);
inc(t);
q[t]:=i;
end;
k:=t;
for i:=n- downto do
begin
while (t>k) and (cross(q[t],i,q[t-])<=) do dec(t);
inc(t);
q[t]:=i;
end;
for i:= to t- do
q[t+i-]:=q[i];
ans:=cross(q[],q[],q[]);
j:=;
k:=;
for i:= to t- do
begin
k:=max(k,i+);
j:=max(j,i+);
while (k<i+t-) and (cross(q[j],q[k+],q[i])>=cross(q[j],q[k],q[i])) do inc(k);
ans:=max(ans,cross(q[j],q[k],q[i]));
while (j<k) and (cross(q[j+],q[k],q[i])>=cross(q[j],q[k],q[i])) do inc(j);
ans:=max(ans,cross(q[j],q[k],q[i]));
end;
writeln(ans/::);
readln(n);
end;
end.
05-08 15:11