Start: Jul, 05, 2019 08:40:00
2019年度暑期短学期达标测试
End: Jul, 05, 2019 11:40:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 3ms
Memory: 1764kB
Author: CT12810441281
In contest: 1281

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
const int inf =0x3f3f3f3f;
using namespace std;	
int cnt=1;
int maxn[1001],minn[1001];	
int check(int a,int b)
{
	for(int i=1;i<=cnt;++i)
	{
		if(a<=maxn[i]&&b<=minn[i])
		return i;
	}
	return 0;
}
int main()
{
	int n;
	cin>>n;
	int a,b;
	cin>>a>>b;
	if(b>=a) swap(a,b);
	maxn[1]=a,minn[1]=b;
	for(int i=1;i<n;++i)
	{
		cin>>a>>b;
		if(b>=a) swap(a,b);
		if(check(a,b))
		{
			int temp=check(a,b);
			maxn[temp]=a,minn[temp]=b;	
		}
		else
		{
			cnt++;
			maxn[cnt]=a,minn[cnt]=b;
		}
	}
	cout<<cnt;
}