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: 7ms
Memory: 1764kB
Author: CT12811551281
In contest: 1281

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

struct book
{
	int h,w;
}sz[1005];
int main()
{
	int n;int sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		int flag=0;
		for(int i=1;i<=sum;i++)
		{
			if(sz[i].h>=a&&sz[i].w>=b)
			{	
				sz[i].h=a;
				sz[i].w=b;
				flag=1;
				break;
			}
			else if(sz[i].w>=a&&sz[i].h>=b)
			{
				sz[i].h=b;
				sz[i].w=a;
				flag=1;
				break;
			}
		}
		if(!flag)
		{
			sum++;
			sz[sum].h=a;
			sz[sum].w=b;
		}
	}
	cout<<sum;
	return 0;
}