The answer sequence must be a lower convex hull, so the addition of the arithmetic progression is a single-peak function, you can first calculate the maximum value, then two to find out 0 points, and then use the segment tree, the resulting range is modified to a arithmetic progression.
This should be better to think about it, although relatively slow ...
#include <cstdio> #define Z int l=1,int r=n,int k=1#define N 50000#define M (l+r>>1) #define P (k<<1) #defi Ne S (k<<1|1) #define K l,r,k#define l l,m,p#define R m+1,r,sdouble a[n*4],b[n*4];void devolve (Z) {if (B[k]) {a[S]=a[k ]+ (m-l+1) * (B[p]=b[s]=b[k]); a[p]=a[k],b[k]=0;}} Double query (int s,z) {if (l!=r) {devolve (K); return S<=m?query (s,l): Query (S,R);} return a[k];} void Amend (double u,double v,int s,int t,z) {if (s==l&&t==r) a[k]=u,b[k]=v;else{devolve (k); if (t<=m) Amend (U, V,S,T,L), else if (s>m) amend (u,v,s,t,r); Else{amend (u,v,s,m,l); Amend (u+ (m-s+1) *v,v,m+1,t,r);}}} Double s,t;int I,j,m,r,l;char k[8];void Solve () {scanf ("%lf%lf", &s,&t), L=1,r=n;while (l!=r) {i=l+ (r-l)/3;j=r- (r-l)/3;if (t* (i-j) <query (i)-query (j)) L=i+1;else R=j-1;} if (S+t*l-t>query (l)) {R=l,l=1;while (l!=r) {i=l+r>>1;if (S+t*i-t>query (i)) R=i;else l=i+1;} J=l,r=n;while (l!=r) {i=l+r+1>>1;if (S+t*i-t>query (i)) L=i;else r=i-1;} amend (s+t*j-t,t,j,l);}} int main () {for (scanf ("%d", &m); m;--m) {scanf ("%s", K), if (*k==80) solve (), else{scanf ("%d", &i);p rintf ("%d\n", (int) query (i)/100);}}
bzoj1568: [Jsoi2008]blue Mary opens company three points + two points + segment tree