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

#include<stdio.h>
#include<string.h>
int main(void)
{
	int n,i,c[1001],k[1001],sum,p[1003],j,flag;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&c[i],&k[i]);
	}
	sum=1;p[1]=0;
	for(i=1;i<n;i++)
	{
		flag=0;
		for(j=1;j<=sum;j++)
		{
			if(c[i]<=c[p[j]]&&k[i]<=k[p[j]]&&flag==0){p[j]=i;flag=1;}
			else if(c[i]<=k[p[j]]&&k[i]<=c[p[j]]&&flag==0){p[j]=i;flag=1;}
			else if(j==sum&&flag==0) {sum++;p[sum]=i;}
		}
	}
	printf("%d\n",sum);
}