南阳236----心急的C小加

时间:2024-07-06 10:06:26
 #include<cstdio>
#include<algorithm>
#define inf 1<<30
using namespace std; typedef struct
{
int l,w;
} cus;
cus a[],d[];
int top; int cmp(cus x,cus y)
{
if(x.l == y.l)
return x.w < y.w;
return x.l < y.l;
} void solven(int x,int y)
{
int i;
for(i=; i<=top; ++i)
if(d[i].l <= x && d[i].w <= y)
{
d[i].l = x;
d[i].w = y;
break;
}
if(i == top + )
{
d[++top].l = x;
d[top].w = y;
}
} int main()
{
int t,n,i;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=; i<n; ++i)
{
scanf("%d%d",&a[i].l,&a[i].w);
}
sort(a,a+n,cmp);
d[].l = d[].w = inf;
for(i=top=; i<n; ++i)
solven(a[i].l,a[i].w);
printf("%d\n",top);
}
return ;
}