凸包写挂了调了好久qaq
忘了凸包上的点的横坐标并不是等距的qaq
首先分块,维护前缀和数组,每块维护一个凸包,那么每一块中的答案都在凸包上可以二分求出
对于区间操作,实际上相当于在区间内加一个等差数列,区间以后加一个常数,而这是不改变凸包的,所以打个标记即可
时间复杂度O(n*sqrt(n)*log n) 窝写的常数好大qaq
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
typedef long long LL;
inline int read()
{
int x=0;bool f=0;char c=getchar();
for (;c<'0'||c>'9';c=getchar()) f=c=='-'?1:0;
for (;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
return f?-x:x;
}
const int N=100010,B=300,S=N/B+3;
const LL oo=(LL)1e18;
int n,m,ln[S],bn=0,bl[N],stk[N],st,cov[S][B+10],ct[S];
LL A[N],fir[S],add[S];
inline void push_down(int x)
{
LL rec=fir[x];
for (int i=ln[x