就比如说最基础的,一刀最多切2个,两刀最多切4个,三刀最多切7个,n刀最多切1+1+······+n个,所以只要叉积维护一下前缀和就好了
#include<bits/stdc++.h>
#define db double
using namespace std;
const int maxn=1e5+10;
db x[maxn],y[maxn],sum1[maxn],sum2[maxn],ans;
int main()
{
int n,q,s,t;
scanf("%d%d",&n,&q);
for(int i=1;i<=n;i++)
scanf("%lf%lf",&x[i],&y[i]);
y[n+1]=y[1],x[n+1]=x[1];
for(int i=1;i<=n;i++)
{
sum1[i]=sum1[i-1]+x[i]*y[i+1];
sum2[i]=sum2[i-1]+y[i]*x[i+1];
}
db S=(sum1[n]-sum2[n])/2;
while(q--)
{
scanf("%d%d",&s,&t);
if(s>t)swap(s,t);
db t1=sum1[t-1]-sum1[s-1]+x[t]*y[s];
db t2=sum2[t-1]-sum2[s-1]+y[t]*x[s];
db tmp=(t1-t2)/2;
ans=max(ans,min(tmp,S-tmp));
}
printf("%.2lf\n",ans);
}