题目:
代码:
#include<iostream>
using namespace std;
#define M 105
#include<algorithm>
struct test
{
int beg;
int end;
}a[M];
bool cmp(test t1,test t2)
{
return t1.end<t2.end;
}
int main()
{
int n;cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].beg>>a[i].end;
}
sort(a+1,a+n+1,cmp);
int temp=-100,count=0;
for(int i=1;i<=n;i++)
{
if(a[i].beg>=temp)
{
temp=a[i].end;
count++;
}
}
cout<<count<<endl;
}