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

#include<stdio.h>
int main()
{
	int i,n,h,w,s=1,f;
	int hm[1001]={2147483647},wm[1001]={2147483647};
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d %d",&h,&w);
		f=0;
		for(i=1;i<=s;i++)
		{
			if(h<=hm[i]&&w<=wm[i])
			{
				hm[i]=h;
				wm[i]=w;
				f=1;
				break;
			}
			else if(h<=wm[i]&&w<=hm[i])
			{
				hm[i]=w;
				wm[i]=h;
				f=1;
				break;
			}
		}
		if(f==0)
		{
			s++;
			hm[s]=h;
			wm[s]=w;
		}
	}
	printf("%d\n",s-1);
}