nyoj 236 WA

来源:互联网 发布:知乎 电视机选取 编辑:程序博客网 时间:2024/04/28 11:48
 
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
struct c
{
 int l,w;
};
bool cmp(c x,c y)
{
 if(x.l==y.l)
  return x.w<y.w;
 return x.l<y.l;
}
int main()
{
 c s[5002];
 int t,n,i,j,k,temp;
 cin>>t;
 while(t--)
 {
  cin>>n;
  for(i=0;i<n;i++)
   scanf("%d%d",&s[i].l,&s[i].w);
  sort(s,s+n,cmp);
  k=n;
  for(i=0;i<n;i++)
  {
   if(s[i].w!=0)
   {
    temp=s[i].w;
    for(j=i+1;j<n;j++)
    {
     if(s[j].w>=temp)
     {
      k--;
      temp=s[j].w;
      s[j].w=0;
     }
    }
   }
  }
  printf("%d\n",k);
 }
 return 0;
}       
原创粉丝点击