凸包算法+枚举
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 /* 2 凸包 3 顺时针!!!! 4 */ 5 #include<stdio.h> 6 #include<string.h> 7 #include<stdlib.h> 8 #include<algorithm> 9 #include<iostream> 10 #include<queue> 11 #include<stack> 12 #include<math.h> 13 #include<map> 14 using namespace std; 15 const int maxn = 50005; 16 struct node{ 17 int x,y; 18 }; 19 bool operator < ( const node &l,const node &r ){ 20 return l.y<r.y||( l.y==r.y&&l.x<r.x ); 21 } 22 node pnt[ maxn ],res[ maxn ]; 23 int mult( node sp,node ep,node op ){ 24 return (sp.x - op.x) * (ep.y - op.y)-(ep.x - op.x) * (sp.y - op.y); 25 } 26 /* 27 ep 28 | 29 | 30 op----sp 31 ( from sp to ep ) 32 */ 33 int graham( int n ){ 34 int i, len, k = 0; 35 int top = 1; 36 sort(pnt, pnt + n); 37 if (n == 0) return 0; res[0] = pnt[0]; 38 if (n == 1) return 1; res[1] = pnt[1]; 39 if (n == 2) return 2; res[2] = pnt[2]; 40 for (i = 2; i < n; i++) { 41 while (top && mult(res[ top ], pnt[ i ], res[top-1])>=0 )//( cross : from top to i ) 42 top--; 43 res[++top] = pnt[i]; 44 } 45 len = top; res[++top] = pnt[n - 2]; 46 for (i = n - 3; i >= 0; i--) { 47 while (top!=len && mult(res[ top ], pnt[ i ], res[top-1])>=0 ) 48 top--; 49 res[++top] = pnt[i]; 50 } 51 return top; // 返回凸包中点的个数 52 } 53 int main(){ 54 int n; 55 while( scanf("%d",&n)!=EOF ){ 56 for( int i=0;i<n;i++ ) 57 scanf("%d%d",&pnt[i].x,&pnt[i].y); 58 int cnt=graham( n ); 59 double ans=0; 60 for( int i=0;i<cnt;i++ ){ 61 for( int j=i+1;j<cnt;j++ ){ 62 for( int k=j+1;k<cnt;k++ ){ 63 double tmp=mult( res[i],res[k],res[j] ); 64 ans=max( ans,tmp ); 65 } 66 } 67 } 68 ans*=0.5; 69 printf("%.2lf\n",ans); 70 } 71 return 0; 72 }