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

#include <stdio.h>
int main() {
  int n, h, w, num, r, i, j;
  int a[1000][2];
  scanf("%d", &n);
  
  for(j = 0;j < n;j ++){
  	r = 0;
  	scanf("%d %d", &h, &w);
  	if(w > h) {
  	  int t = w;
	  w = h;
	  h = t;	
	}  	
	if(j == 0) {
      a[0][0] = h;
      a[0][1] = w; 
	  num = 1; 	
	}else {
		for(i = 0;i < num;i ++) {
			if(h <= a[i][0] && w <= a[i][1]) {
		       a[i][0] = h;
		       a[i][1] = w;
		       r = 1;
		       break;
		   }
	    }
	    if(r == 0){
	      a[num][0] = h;
	      a[num][1] = w;
		  num ++;
		}			
	}
  }
  printf("%d\n", num);
  return 0;
}