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: 8ms
Memory: 1716kB
Author: 2017212212174
In contest: 1269

#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

struct xixi{
	int l,r;
}p[102];

bool cmp(const xixi &a,const xixi &b){
	if(a.r!=b.r)return a.r<b.r;
	else return a.l<b.l;
}

int main(){
	int n;
	while(cin>>n){
		if(!n)break;
			for(int i=0;i<n;i++){
		cin>>p[i].l>>p[i].r;
	}
	sort(p,p+n,cmp);
	int r=p[0].r,date=1;
	for(int i=1;i<n;i++){
		if(p[i].l>=r){
			r=p[i].r;
			date++;
		}
	}
	cout<<date<<endl;
	}

	return 0;
}