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

#include<stdio.h>
int main()
{
	int n,h[1010],w[1010],ans=1,t,i,j,h1[1010],w1[1010];
	scanf("%d",&n);
	for(i=0;i<n;++i)
	{
		scanf("%d %d",&h[i],&w[i]);
	}
	h1[0]=h[0];
	w1[0]=w[0];
	
	for(i=1;i<n;++i)
	{
		t=0;
		for(j=0;j<ans;++j)
		{
			if((h[i]<=h1[j]&&w[i]<=w1[j])||(h[i]<=w1[j]&&w[i]<=h1[j]))
		    {
	    		h1[j]=h[i];
	    		w1[j]=w[i];
				break;
	    	}
	    	else
	    	{
	    		t++;
	    	}
		}
		if(t==ans)
		{
			ans++;
			h1[ans-1]=h[i];
			w1[ans-1]=w[i];
		}
	}
	
	printf("%d\n",ans);
}