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

#include<stdio.h>

int main(){
	int t,h,w,a1,b1,i,sum=0;
	int a[1002],b[1002],c[1002];
	scanf("%d",&t);
	for(i=0;i<1000;i++){
		a[i]=0;
		b[i]=0;
		c[i]=0;
}   
	while(t--){
		scanf("%d%d",&h,&w);
		if(h>w){
			a1=w;
			b1=h;
		}
		else if(h<=w){
			a1=h;
			b1=w;
		}
		for(i=0;i<1001;i++){
			if(c[i]==0){
				a[i]=a1;
				b[i]=b1;
				c[i]=1;
				break;
			}
			if(a1<=a[i]&&b1<=b[i]&&c[i]!=0){
				a[i]=a1;
				b[i]=b1;
				c[i]=1;
				break;
			}
		}
	}
	for(i=0;i<1000;i++){
		if(c[i]!=0)
			sum+=1;
	}
	printf("%d\n",sum);
}