![Luogu P3028 [USACO10OCT]汽水机Soda Machine](http://pic.xiahunao.cn/yaotu/Luogu P3028 [USACO10OCT]汽水机Soda Machine)
题目链接传送门离散化一下维护一个最值啊学数据结构学傻了#includeiostream#includecstdio#includecstring#includecstdlib#includecomplex#includealgorithm#includeclimits#includequeue#includemap#includeset#includevector#includeiomanip#defineA 1000010#defineB 2010usingnamespacestd;typedeflonglongll;structnode{intx,y;}e[A];intn,t[A],cnt,mx;structT{intl,r,w,f;}tree[A];voidbuild(intk,intl,intr){tree[k].ll;tree[k].rr;if(lr)return;intm(lr)1;build(k1,l,m);build(k1|1,m1,r);}voiddown(intk){tree[k1].ftree[k].f;tree[k1|1].ftree[k].f;tree[k1].wtree[k].f;tree[k1|1].wtree[k].f;tree[k].f0;}voidadd(intk,intl,intr){if(tree[k].llandtree[k].rr){tree[k].w;tree[k].f;return;}if(tree[k].f)down(k);intm(tree[k].ltree[k].r)1;if(lm)add(k1,l,r);if(rm)add(k1|1,l,r);tree[k].wmax(tree[k1].w,tree[k1|1].w);}intmain(intargc,charconst*argv[]){cinn;for(inti1;in;i)cine[i].xe[i].y,t[cnt]e[i].x,t[cnt]e[i].y;sort(t1,tcnt1);intmunique(t1,tcnt1)-t-1;for(inti1;in;i)e[i].xlower_bound(t1,tm1,e[i].x)-t,e[i].ylower_bound(t1,tm1,e[i].y)-t,mxmax(mx,max(e[i].x,e[i].y));build(1,1,mx);for(inti1;in;i)add(1,e[i].x,e[i].y);couttree[1].wendl;}