hdu 1051
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn = 10000+10;
struct Node{
int l;
int w;
bool vis; //重要
}node[maxn];
bool cmp(Node a, Node b)
{
if(a.l != b.l) return a.l < b.l; //先按照长度排序
else return a.w < b.w; //再按照重量排序
}
int main()
{
int T;
int n;
scanf("%d", &T);
while(T--)
{
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
scanf("%d%d", &node[i].l, &node[i].w);
node[i].vis = 0; //每根木棍均未操作
}
sort(node, node+n, cmp);
int s = 0;
for(int i = 0; i < n; i++)
{
if(node[i].vis)
continue; //如果已经操作过,直接跳出
s++; // 前面没有可以使它直接操作的木棍
node[i].vis = 1;
int weight = node[i].w; //由于长度已排序,所以只用记录重量
for(int j = i+1; j < n; j++)
{
if(!node[j].vis && node[j].w >= weight) //如果满足不用+时间
{
node[j].vis = 1; //直接操作
weight = node[j].w; //同时更新下一根可以操作的 w 界限
}
}
}
printf("%d\n", s);
}
return 0;
}