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: 1120kB
Author: CT12811781281
In contest: 1281

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
struct book{
   int h;
   int w;
};
int main(){
	int n,temp,i,j,s=1,count=0;
	struct book a[1002],b[1002];
	scanf("%d",&n);
	for(i=0;i<n;i++){
	   scanf("%d %d",&a[i].h,&a[i].w);
	   if(a[i].h<a[i].w){
	       temp=a[i].h;
		   a[i].h=a[i].w;
		   a[i].w=temp;
	   }
	}
	b[0].h=a[0].h;
	b[0].w=a[0].w;
	for(i=1;i<n;i++){
		count=0;
		for(j=0;j<s;j++){
			if(a[i].h<=b[j].h&&a[i].w<=b[j].w){
				b[j].h=a[i].h;
				b[j].w=a[i].w;
				count=1;
				break;
			}
		}
		if(count==0){
			b[s].h=a[i].h;
			b[s].w=a[i].w;
			s++;
		}
	}
	printf("%d\n",s);
}