# 膜拜(离散化差分模板题)

4
3 5
4 8
1 2
5 10


3

#include <bits/stdc++.h>
using namespace std;
#define wuyt main
typedef long long ll;
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
ll maxx=-1,minn=inf;
ll num[maxn],a[maxn],num2[maxn];
ll res,ans;
int n;
ll cnt[maxn];
pair<ll,ll> together[maxn];
vector <ll> vet;
int main()
{
for(int i=1;i<=n;i++){
vet.push_back(left);
vet.push_back(right);
together[i]={left,right};
}
sort(vet.begin(),vet.end());
vet.erase(unique(vet.begin(),vet.end()),vet.end());

for(int i=1;i<=n;i++){
ll left=together[i].first;
ll right=together[i].second;
ll templeft=lower_bound(vet.begin(),vet.end(),left)-vet.begin();
ll tempright=lower_bound(vet.begin(),vet.end(),right)-vet.begin();
num[templeft]+=1;
num[tempright+1]-=1;
}
int len=vet.size();
for(int i=1;i<len;i++) num[i]+=num[i-1];
ans=num[0];
for(int i=1;i<len;i++)
if(num[i]>=ans)
ans=num[i];
cout<<ans<<endl;
return 0;
}


04-28 616

11-13 744
04-13 552
05-15 498
08-08 851
10-06 153