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

#include<stdio.h>
int main() {
	int n,i,t,sum=1,w,j,k;
	scanf("%d",&n);
	int a[n],b[n],p[n];
	p[0]=0;
	for(i=0; i<n; i++) {
		scanf("%d %d",&a[i],&b[i]);
		if(a[i]<b[i]) {
			t=b[i];
			b[i]=a[i];
			a[i]=t;
		}
	}
	for(i=1; i<n; i++) {
		w=0;
		for(k=0; k<sum; k++) {
			if(a[i]<=a[p[k]]&&b[i]<=b[p[k]]) {
				p[k]=i;
				w=1;
				break;
			}
		}
		if(w==1) {
			continue;

		} else {
			sum=sum+1;
			p[sum-1]=i;
		}


	}
	printf("%d",sum);
	return 0;
}