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

#include<bits/stdc++.h>
#define ll long long 
using namespace std;

const int maxn=105;
const int inf=0x3f3f3f3f;

struct node
{
	int x,y;
}p[maxn];

bool cmp(const node &a,const node &b)
{
	if(a.y==b.y)	return a.x>b.x;
	return a.y<b.y;
}

int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		if(n==0)	break;
		for(int i=1;i<=n;i++)
		{
			scanf("%d %d",&p[i].x,&p[i].y);
		}
		sort(p+1,p+1+n,cmp);
		int ans=1,q=p[1].y;
		for(int i=2;i<=n;i++)
		{
			if(p[i].y==p[i-1].y)	continue;
			if(p[i].x<q)	continue;
			ans++;
			q=p[i].y;
		}
		printf("%d\n",ans);
	}
}