题解:
前缀和维护
f[a]++,f[b+1]--
然后F[i]+=f[i-1]
代码:
#include<bits/stdc++.h> using namespace std; const int N=1000005; int a,b,n,f[N],ans; int main() { scanf("%d",&n); while (n--) { scanf("%d%d",&a,&b); f[a]++;f[b+1]--; } for (int i=1;i<N;i++)f[i]+=f[i-1]; for (int i=1;i<N;i++)ans=max(ans,f[i]); printf("%d",ans); }