HZNUOJ


Problem_ID: H
Result: Accepted
Time: 7ms
Memory: 1716kB
Author: 2017212212182
In contest: 1269

#include<iostream>
#include<algorithm>
using namespace std;
struct jiemu
{
int s;
int e;
};
bool cmp(jiemu x,jiemu y)
{return x.e<y.e;
}
int main(){
	int t;
	struct jiemu a[100];

	while (cin>>t&&t){
	for(int i=0;i<t;i++)
			cin>>a[i].s>>a[i].e;
	sort(a,a+t,cmp);
	int end=a[0].e,count=1;
	for(int i=1;i<t;i++)
		if(a[i].s>=end){end=a[i].e;count++;}
		cout<<count<<endl;
	}
	return 0;
	}