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: CT12811101281
In contest: 1281

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	int n,h,w,flag;
	int i,j,k,l,temp;
	
	int a[1001][2];
	scanf("%d",&n);
	scanf("%d %d",&h,&w);
	if(h<w){
		temp=h;
		h=w;
		w=temp;
	}
	a[0][0]=h;
	a[0][1]=w;
	i=0;
	k=1;
	for(l=0;l<n-1;l++){
		flag=0;
		scanf("%d %d",&h,&w);
		for(i=0;i<k;i++){
			if(h<w){
				temp=h;
				h=w;
				w=temp;
			}
			if(a[i][0]>=h&&a[i][1]>=w){
				a[i][0]=h;
				a[i][1]=w;
				flag=1;
				break;
			}
		}
		if(flag==0){
			a[k][0]=h;
			a[k][1]=w;
			k++;
		}
	}
	printf("%d\n",k);
}