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: 4ms
Memory: 1756kB
Author: CT12812111281
In contest: 1281

#include<iostream>
#include<cmath>
#include<cstring>
#include<stack>
#include<set>
#include<algorithm>
#include<map>
#include<cstdlib>
using namespace std;

int main()
{
	int n;
	int max1,max2,min1,min2;
	int a[1002],b[1002];
	scanf("%d",&n);
	int h,w;
	scanf("%d %d",&h,&w);
	a[1]=h;
	b[1]=w;
	int ans=1;
	for(int i=1;i<n;i++)
	{
	int flag=0;
		scanf("%d %d",&h,&w);
		for(int j=1;j<=ans;j++)
		{
			 max1=max(h,w);
			 max2=max(a[j],b[j]);
			 min1=min(h,w);
			 min2=min(a[j],b[j]);
			if(max1<=max2&&min1<=min2)
			{
				flag=1;
				a[j]=max1;
				b[j]=min1;
				break;
			}
		}
		if(flag==0)
		{
			ans++;
			a[ans]=max1;
			b[ans]=min1;	
		}
		
	}
	printf("%d\n",ans);
}