#include #include #include #include #include using namespace std; const int N = 400500; const int M = 800500; int n,m; int xu[N]; bool can[N]; int lisan[N]; int vx[N]; int ever[N]; int last[N]; struct Info { int a,b,c; }info[N]; struct Que { int x; int l,r; int num; }que[M]; int tree[N]; int qz[N]; int sc[N]; int cc; int getint() { int res=0; char ch=getchar(); while((ch<'0' || ch>'9') && ch!='-') ch=getchar(); bool fan=0; if(ch=='-') { fan=1; ch=getchar(); } while('0'<=ch && ch<='9') { res=res*10+ch-'0'; ch=getchar(); } if(fan) res=-res; return res; } int Erfen(int x) { int l=1,r=lisan[0]; while(l<=r) { int mid=(l+r)/2; if(lisan[mid]==x) return mid; if(lisan[mid]y.a) return -1; if(x.by.b) return -1; if(x.cy.c) return -1; return 0; } bool cmp(Info x,Info y) { return(cmpx(x,y)>=0); } int Ef(Info x) { int l=1,r=cc; while(l<=r) { int mid=(l+r)/2; int now=cmpx(x,info[mid]); if(now==0) return mid; if(now==1) r=mid-1; else l=mid+1; } } bool cmx(Que x,Que y) { return(x.xr || r>n) { sc[i]=0; continue; } cc++; que[cc].num=i; que[cc].l=l; que[cc].r=r; que[cc].x=r; sc[i]=qz[r]-qz[l-1]; } sort(que+1,que+cc+1,cmx); memset(tree,0,sizeof tree); int point=0; for(i=1;i<=cc;i++) { while(point