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: 8ms
Memory: 1120kB
Author: CT12811021281
In contest: 1281

#include<stdio.h>
#include<math.h>
int main(){
	int n,i,j,sum = 1;
	int h[1001],k[1001];
	int hm[1001],km[1001];
	scanf("%d",&n);
	for(i = 0;i<n;i++){
		scanf("%d %d",&h[i],&k[i]);
	}
	hm[0] = h[0];km[0] = k[0];
	for(i = 1;i<n;i++){
		for(j = 0;j<=sum-1;j++){
			if((h[i]<=hm[j] && k[i] <=km[j]) || (h[i]<=km[j] && k[i] <= hm[j])){
				hm[j] = h[i];
				km[j] = k[i];
				break;
			}else if(j == sum-1){
				sum++;	
				hm[sum-1] = h[i];
				km[sum-1] = k[i];
				
				break;
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}