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

#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
	int n;
	scanf("%d",&n);
	int h[1010],w[1010],dh[1010],dw[1010];
	int x=1;
	scanf("%d%d",&h[0],&w[0]);
	dh[1]=h[0];
	dw[1]=w[0];
	for(int i=1;i<n;++i){
		scanf("%d%d",&h[i],&w[i]);
		int flag=0;
		for(int j=1;j<=x;++j){
			if(h[i]<=dh[j]&&w[i]<=dw[j]){
				dh[j]=h[i];
				dw[j]=w[i];
				flag=1;
				break;
			}
			else if(h[i]<=dw[j]&&w[i]<=dh[j]){
				dw[j]=h[i];
				dh[j]=w[i];
				flag=1;
				break;
			}
		}
		if(flag==0){
				x+=1;
				dh[x]=h[i];
				dw[x]=w[i];
			}
	}
	printf("%d",x);
}