//2629969 2011-08-16 16:36:14 Accepted 1025 C 10 200 ylwh@Unknown
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 5001
struct node
{
int l, w;
}s[N];
int cmp(const void * a, const void * b)
{
if( ( (struct node *)a )->l != ((struct node *)b) ->l)
return ( (struct node *)a )->l - ( (struct node *)b )->l;
else
return ( (struct node *)a )->w - ( (struct node *)b )->w;
}
int main()
{
int t, n, staue[N], ans, i, j, temp;
scanf("%d", &t);
while(t--)
{
scanf("%d", &n);
for(i=0; i<n; i++)
{
scanf("%d%d", &s[i].l, &s[i].w);
staue[i] = 0;
}
qsort(s, n, sizeof(s[0]), cmp);
ans = 0;
for(i=0; i<n; i++)
if(staue[i] == 0)
{
ans++;
temp = s[i].w;
for(j=i+1; j<n; j++)
if(staue[j] == 0 && s[j].w >= temp)
{
staue[j] = 1;
temp = s[j].w;
}
}
printf("%d\n", ans);
}
return 0;
}
ZOJ 1025 Wooden Sticks【非DP做法】
最新推荐文章于 2011-08-21 00:56:14 发布