First find the point at the convex hull, then n^2 enumerate every two points x, Y, then the left and right side of the furthest point.
As you can see, when x does not change to a monotonically increasing, the two points farthest from both sides are also monotonically increasing.
You can then use a rotating jam.
#include <cstdlib> #include <cstdio> #include <cstring> #include <cmath> #include <iostream > #include <algorithm> #include <cctype> #define REP (i, L, R) for (int. i=l; i<=r; i++) #define DOWN (i, L, R) for (int i=l; i>=r; i--) #define MAXN 2009#define pi ACOs ( -1) #define EPS 1e-11using namespace std;inline int read () {int x =0, f=1; Char Ch=getchar (), while (!isdigit (CH)) {if (ch== '-') f=-1; Ch=getchar ();} while (IsDigit (CH)) x=x*10+ch-' 0 ', Ch=getchar (); return x*f;} struct p{double x, y;} P[MAXN], S[MAXN]; P operator-(p a, p B) {return (p) {a.x-b.x, a.y-b.y};} Double operator * (p a, p b) {return a.x*b.y-a.y*b.x;} Double Dis (p a, p B) {return (a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y);} BOOL CMP (p A, p b) {double t= (a-p[1]) * (b-p[1]), if (t==0) return dis (A, p[1]) <dis (b, p[1]); else return t<0;} int n, top;double ans;int main () {n=read (); Rep (i, 1, N) scanf ("%lf%lf", &p[i].x, &p[i].y); int K=1;rep (i, 2, N) if ( P[i].y<p[k].y | | (P[i].y==p[k].y && p[i].x<p[k].x) K=i;swap (p[1], p[k]); sort (p+2, p+n+1, CMP); s[++top]=p[1]; S[++top]=p[2];rep (i, 3, n) {while (top>1 && (p[i]-s[top-1]) * (S[top]-s[top-1]) <=0) top--;s[++top]=p[i];} S[top+1]=p[1];int A, B;rep (x, 1, top) {a=x%top+1; b= (x+2)%top+1;rep (y, x+2, top) {while (A%top+1!=y && (s[y]-s[x]) * (S[a+1]-s[x]) > (s[y]-s[x]) * (s[a]-s[x)) A=a%top+1;while (b%top+1!=x && (s[b+1]-s[x)) * (S[y]-s[x]) > (s[ B]-S[X]) * (S[y]-s[x]) B=b%top+1;ans=max ((S[y]-s[x]) * (S[a]-s[x]) + (S[b]-s[x]) * (s[y]-s[x]), ans);} printf ("%.3lf\n", ANS/2); return 0;}
BZOJ-1069 [SCOI2007] Maximum land area