题意:给出n条线段求覆盖点 次数最多的条数。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
#define cler(arr, val) memset(arr, val, sizeof(arr))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define IN freopen ("in.txt" , "r" , stdin);
#define OUT freopen ("out.txt" , "w" , stdout);
typedef long long LL;
const int MAXN = 111011;
const int MAXM = 610;
const int INF = 0x3f3f3f3f;
const LL mod = 2147483647;
const double eps= 1e-8;
const double pi=acos(-1.0);
#define lson l,m, rt<<1
#define rson m+1,r,rt<<1|1int len,dig[66];
struct node
{
int p,value;
}po[MAXN<<1];
bool cmp(node a,node b)
{
if(a.p==b.p)
return a.value<b.value;
return a.p<b.p;
}
int main()
{
int t,n;
cin>>t;
while(t--)
{
cin>>n;
for(int i=0;i<n;i++)
{
scanf("%d%d",&po[i*2].p,&po[i*2+1].p);
po[i*2+1].p++;
po[i*2].value=1;
po[i*2+1].value=-1;
}
int ans=0,mx=0;
sort(po,po+2*n,cmp);
for(int i=0;i<2*n;i++)
{
ans+=po[i].value;
mx=max(ans,mx);
}
cout<<mx<<endl;
}
return 0;
}