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

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