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

#include <stdio.h>
#include <math.h>
int main(){
	int T,h,w,sum;
	int a[1000]={0},b[1000]={0};
	scanf("%d",&T);
	while(T){
		scanf("%d %d",&h,&w);
		if(a[0]==0){
			a[0]=h;
			b[0]=w;
			sum=1;
		}
		for(int q=0;a[q]!=0 && b[q]!=0;q++){
			if(h<=a[q]&&w<=b[q]){
				a[q]=h;
				b[q]=w;
				break;
			}else if(h<=b[q]&&w<=a[q]){
				a[q]=w;
				b[q]=h;
				break;
			}else{
 				if(a[q+1]==0&&b[q+1]==0){
				a[q+1]=h;
				b[q+1]=w;
				sum=sum+1;
				break;
				}
			}
		}
		T--;
	}
	printf("%d",sum);
	return 0;
}