# 并不对劲的bzoj4651:loj2086:uoj222:p1712:[NOI2016]区间

##### 题目大意

$$n$$($$n\leq 5*10^5$$)个闭区间$$[L_1,R_1],[L_2,R_2],...,[L_n,R_n]$$($$\forall i\in [1,n],0\leq L_i\leq R_i\leq 10^9$$)

##### 题解

$$n$$个区间按区间长度排序

##### 代码
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define rep(i,x,y) for(register int i=(x);i<=(y);++i)
#define dwn(i,x,y) for(register int i=(x);i>=(y);--i)
#define maxn 500010
#define ls (u<<1)
#define rs (u<<1|1)
#define mi (l+r>>1)
using namespace std;
{
int x=0,f=1;char ch=getchar();
while(!isdigit(ch)&&ch!='-')ch=getchar();
if(ch=='-')f=-1,ch=getchar();
while(isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
return x*f;
}
void write(int x)
{
if(x==0){putchar('0'),putchar('\n');return;}
int f=0;char ch[20];
if(x<0)putchar('-'),x=-x;
while(x)ch[++f]=x%10+'0',x/=10;
while(f)putchar(ch[f--]);
putchar('\n');
return;
}
int n,ext[maxn<<1],cnte,tr[maxn<<3],mk[maxn<<3],ans=-1,m;
struct node{int l,r;}nd[maxn];
bool cmp(node x,node y){return x.r-x.l<y.r-y.l;}
void mark(int u,int k){tr[u]+=k,mk[u]+=k;}
void pd(int u){if(mk[u])mark(ls,mk[u]),mark(rs,mk[u]),mk[u]=0;}
void pu(int u){tr[u]=max(tr[ls],tr[rs]);}
void add(int u,int l,int r,int x,int y,int k)
{
if(x<=l&&r<=y)return mark(u,k);
pd(u);
return pu(u);
}
int getr(int x)
{
int l=1,r=cnte,ans=cnte+1;
while(l<=r)
{
int mid=mi;
if(ext[mid]<x)l=mid+1;
else if(ext[mid]>x)r=mid-1;
else ans=min(ans,mid),r=mid-1;
}
return ans;
}
int jud(int i,int j)
{
int x=tr[1];
if(x>=m)return 1;
}
signed main()
{