Start: Jun, 05, 2019 13:00:00
2019春ACM通识课考试(第一场)
End: Jun, 05, 2019 16:00:00
Time elapsed:
Time remaining:

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;
	}