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

#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int maxn = 110;
const int inf=0x3f3f3f3f;
typedef long long ll;
int n,m,k,t;
int x,y,z;
struct node
{
	int a,b;
}p[maxn];
bool cmp(struct node a,struct node b)
{
	return a.b<b.b;
}
int main()
{
	while(scanf("%d",&n)!=EOF&&n)
	{
		int num=0;
		for(int i=1;i<=n;++i){
			scanf("%d %d",&p[i].a,&p[i].b);
		}
		int ans=0;
		sort(p+1,p+1+n,cmp);
		int t=0;
		for(int i=1;i<=n;++i)
		{
			if(p[i].a>=t)
			{
				++ans;
				t=p[i].b;
			}
		}
		printf("%d\n",ans);
	}
	
}