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

#include<cstdio>
#include <algorithm>
#include <iostream>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=1005;
struct node
{
	int h,w;
}a[maxn];
int main()
{
	int n,sum=1,hmin[maxn],wmin[maxn],flag=1;
	memset(hmin,0,sizeof(hmin));
	memset(wmin,0,sizeof(wmin));
	scanf("%d",&n);
	scanf("%d %d",&a[1].h,&a[1].w);
	hmin[1]=a[1].h;
	wmin[1]=a[1].w;
	for(int i=2;i<=n;i++)
	{
		flag=1;
		scanf("%d %d",&a[i].h,&a[i].w);
		for(int j=1;j<=sum;j++)
		{
			if((a[i].h<=hmin[j]&&a[i].w<=wmin[j])||(a[i].w<=hmin[j]&&a[i].h<=wmin[j]))
			{
				flag=1;
				hmin[j]=a[i].h;
				wmin[j]=a[i].w;
				break;
			}
			else flag=0;
		}
		if(flag==0)
		{
			sum++;
			hmin[sum]=a[i].h;
			wmin[sum]=a[i].w;
		}
	}
		printf("%d\n",sum);


//		system("pause");
}