标签:
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 1001
#include<algorithm>
using namespace std;
struct time
{
int b;
int e;
}s[N];
int cmp(time a,time c)
{
return a.e<c.e ;
}
int main()
{
int t,i,j,h,m;
cin>>t;
while(t--)
{
memset(s,0,sizeof(s));
cin>>m;
for(i=0;i<m;i++)
scanf("%d%d",&s[i].b,&s[i].e);
sort(s,s+m,cmp);
h=i=1;
j=0;
while(i<m)
{
if(s[j].e<s[i].b)
{
h++;
j=i;
i++;
}
else
i++;
}
cout<<h<<endl;
}
return 0;
}自己的代码,感觉是一样,但是提交总是编辑错误,什么原因。
这题主要用到结构体排序2 2 1 10 10 11 3 1 10 10 11 11 20
1 2
标签:
原文地址:http://blog.csdn.net/xjcjichao10/article/details/51340115