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

#include <stdio.h>
int main(void){
	int n,h,w,i,j;
	scanf("%d",&n);
	int hm[1000]={0},wm[1000]={0};
	int sum=0;
	for(i=0;i<n;i++){
		scanf("%d %d",&h,&w);
		if(i==0){
			hm[i]=h;
			wm[i]=w;
			sum=sum+1;
		}
		else{
			int flag=1;
			for(j=0;j<i;j++){
				if(h<=hm[j]&&w<=wm[j]){
					hm[j]=h;
					wm[j]=w;
					flag=0;
					break;
				}
				else if(h<=wm[j]&&w<=hm[j]){
					hm[j]=w;
					wm[j]=h;
					flag=0;
					break;
				}
			}
			if(flag){
				sum=sum+1;
				hm[i]=h;
				wm[i]=w;
			}
		}
	}
	printf("%d\n",sum);
return 0;
}