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: 1128kB
Author: CT12810461281
In contest: 1281

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

//int h[1001], w[1001];
//int h1[1001], w1[1001];
int a[1001], b[1001];
int main(){
	int n;
	scanf("%d", &n);
	int h, w, h1, w1;
	int i;
	int num = 1;
	for(i = 0; i< n; i++){
		scanf("%d %d", &h, &w);
		if(i==0){
			a[1] = h;
			b[1] = w;
		} else{
			int t;
			for(t = 1; t <= num ; t++){
				if(h <= a[t]&& w<= b[t]){
					a[t] = h;
					b[t] = w;
					break;
				} else if(h <= b[t]&& w <= a[t]){
					a[t] = w;
					b[t] = h;
					break;
				} else {
					if(t==num){
						num++;
						a[num] = h;
						b[num] = w;
						break;
					}	
				}
			}
			
		}
	}
	printf("%d", num);
	
	return 0;
}