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: 1720kB
Author: 2017212212292
In contest: 1269

#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
const int inf=0x3f3f3f3f;
map<string,int>mp;
struct nd
{
	int be,en;
}tv[110];
int cmp(nd x,nd y)
{
	return x.en<y.en;
}
int main()
{
	int t;
	while(cin>>t)
	{
		if(t==0)
			break;
		for(int i=0;i<t;i++)
			cin>>tv[i].be>>tv[i].en;
		int ans=1;
		sort(tv,tv+t,cmp);
		nd pos=tv[0];
		for(int i=1;i<t;i++)
		{
			if(tv[i].be>=pos.en)
			{
				ans++;
				pos=tv[i];
			}
		}
		cout<<ans<<endl;
	}
}