首先朴素算法极为简单
n^3对吧
然后思考挂上log
排序
然后枚举第一个点
接着再按向量位置关系越靠右越好排序
接着维护一个向量后缀和就完了。
但是这个题卡精度。
long double 就好了
#include<bits/stdc++.h>
using namespace std;
const int N=3e4;
#define lb long double
const lb eps=1e-21;
const lb INF=1e21;
int cmp(lb A){
if(fabs(A)<eps)return 0;
else return (A>0)?1:-1;
}
int equal(lb A,lb B){
return (cmp(A-B)==0);
}
struct Point{
lb x,y;
Point(lb _x=0,lb _y=0):x(_x),y(_y){}
friend Point operator + (Point A,Point B) {return Point(A.x+B.x,A.y+B.y);}
friend Point operator - (Point A,Point B) {return Point(A.x-B.x,A.y-B.y);}
friend Point operator * (Point A,lb k){return Point(A.x*k,A.y*k);}
friend Point operator / (Point A,lb k){return Point(A.x/k,A.y/k);}
lb ang(){return atan2(y,x);}
void read(){scanf("%Lf%Lf",&x,&y);}
}p[N],tmp[N];
int top=0;
lb Cross(Point A,Point B){
return (A.x*B.y-A.y*B.x);
}
bool cmpCross(Point A,Point B){
return(cmp(Cross(A,B))>0);
}
bool cmpheight(Point A,Point B){
return A.y<B.y||(A.y==B.y&&A.x<B.x);
}
int n;
lb ans=0;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
p[i].read();
}
sort(p+1,p+1+n,cmpheight);
for(int i=1;i<=n;i++){
top=0;
for(int j=i+1;j<=n;j++){
tmp[++top]=p[j]-p[i];
}
sort(tmp+1,tmp+1+top,cmpCross);
Point sum=Point(0,0);
for(int j=top;j>=1;j--){
ans+=Cross(sum,tmp[j]);
sum=sum-tmp[j];
}
}
printf("%.1Lf",ans/2);
// cout<<ans/2;
}