题目
A C C o d e \mathcal AC \ Code AC Code
#include<bits/stdc++.h>
#define maxn 500005
#define LL long long
#define lc u<<1
#define rc lc|1
#define inf 1e17
using namespace std;
int n,m,a[maxn],ra[maxn<<1],b[maxn];
LL x[maxn],y[maxn];
map<LL,int>mAp;
int cnt;
struct block{
int xl,xr,yl,yr;
bool operator <(const block &B)const{
return xl < B.xl;
}
}B[maxn];
int mxp[maxn<<2];
LL mx[maxn<<2],ad[maxn<<2];
void upd(int u){
if(mx[lc] > mx[rc]) mx[u] = mx[lc] , mxp[u] = mxp[lc];
else mx[u] = mx[rc] , mxp[u] = mxp[rc];
}
void dtp(int u,LL v){
ad[u] += v;mx[u] += v; }
void dt(int u){
if(ad[u]) dtp(lc,ad[u]),dtp(rc,ad[u]),ad[u]=0;
}
void Build(int u,int l,int r){
ad[u] = 0;
if(l==r) return (void)(mx[u]=y[m]-x[l],mxp[u]=l,ad[u]=0);
int m=l+r>>1;
Build