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: 1780kB
Author: CT12812371281
In contest: 1281

#include <cstdio>
#include <iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<stack>
using namespace std;
int n,m;
int i,j;
bool cmp(const char a,const char b){
	return a<b;
}
struct node{
	int h;
	int w;
}book[1145];
int s[1145][3];
int main()
{
	scanf("%d",&n);
	int sum=1;

	scanf("%d %d",&book[1].h,&book[1].w);
	s[1][1]=book[1].h,s[1][2]=book[1].w;
	for(i=2;i<=n;++i){
		scanf("%d %d",&book[i].h,&book[i].w);
		int flag=0;
		for(j=1;j<=sum;++j)
		{
			if((book[i].h<=s[j][1]&&book[i].w<=s[j][2])||(book[i].h<=s[j][2]&&book[i].w<=s[j][1])){
				flag=1;
				if(book[i].h<=s[j][1]&&book[i].w<=s[j][2]){
					s[j][1]=book[i].h,s[j][2]=book[i].w;
				}
				else if(book[i].h<=s[j][2]&&book[i].w<=s[j][1]){
					s[j][1]=book[i].w,s[j][2]=book[i].h;
				}
			}
			if(flag) break;
		}
		if(!flag)
		{
			s[sum+1][1]=book[i].h,s[sum+1][2]=book[i].w;
			sum++;
		}
	}
	printf("%d\n",sum);
	return 0;
}