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

#include<stdio.h>
#include<string.h>
#include<math.h>
#define PI 3.141592
int a[1000];
int b[1000];
int main (void) {
	int i,n,h,k,ans=0;
	a[0]=b[0]=0;
	scanf("%d",&n);
	while(n--) {
		scanf("%d %d",&h,&k);	
		for (i=0; i<=ans; i++) {
			if (h<=a[i]&&k<=b[i]) {
				a[i]=h;
				b[i]=k;
				break;
			} else if (h<=b[i]&&k<=a[i]) {
				b[i]=h;
				a[i]=k;
				break;
			}
		}		
		if (i>ans) {
			a[ans]=h;
			b[ans]=k;
			ans++;
		}
	}
	printf("%d",ans);
}