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

#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
	int a[1002],b[1002],c[1002],d[1002];
	int i,j,n,temp;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	temp=1;
	c[1]=a[1];
	d[1]=b[1];
	for(i=2;i<=n;i++){
		for(j=1;j<=temp;j++){
			if((a[i]<=c[j]&&b[i]<=d[j])||(a[i]<=d[j]&&b[i]<=c[j])){
			c[j]=a[i];
			d[j]=b[i];
			break;
		}
		else{
			if(j==temp){
			temp=temp+1;
			c[temp]=a[i];
			d[temp]=b[i];
			break;
			}
		}
		}
	}
	printf("%d\n",temp);
}