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: 2018212212174
In contest: 1269

#include <bits/stdc++.h>
using namespace std;
struct node
{
	int st ;
	int ed ;
}arr[110] ;
bool com(node x , node y)
{
	if(x.ed != y.ed)
		return x.ed < y.ed ;
	return x.st < y.st ;
}
int main(int argc, char const *argv[])
{
	int n ;
	while(scanf("%d",&n)!=EOF)
	{
		if(n == 0) break ;
		for(int i = 0 ; i < n ; ++ i)
		{
			scanf("%d %d",&arr[i].st,&arr[i].ed) ;
		}
		sort(arr,arr+n,com) ;
		int tot = 1 ;
		int pre = arr[0].ed ;
		for(int i = 1 ; i < n ; ++ i)
		{
			if(arr[i].st >= pre)
			{
				tot ++ ;
				pre = arr[i].ed ;
			}
		}
		cout << tot << endl ;
	}
	return 0;
}