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

#include<stdio.h>
int main()
{
	int n,N;
	int h,w;
	int a[10000],b[10000];
	int i=0,j=0;
	scanf("%d",&n);
	N=n;
	while(n--)
	{
		scanf("%d%d",&h,&w);
		if(n==N)
		{
			a[1]=h,b[1]=w;
			j=1; 
			h=0,w=0;
		}
		else
		{
			for(i=1;i<=j;++i)
			{
				if((h<=a[i]&&w<=b[i])||(h<=b[i]&&w<=a[i]))
				{
					a[i]=h,b[i]=w;
					h=0,w=0;
					break;
				}
			}
			if(h!=0&&w!=0)
			{
				j++;
				a[j]=h,b[j]=w;
			}
		}
		
	}
	printf("%d\n",j);
	return 0;
}