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

#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<ctype.h>
using namespace std;
int main()
{ 
  int n,h,w,i,sum,h1,w1,p;
   scanf("%d",&n);
   scanf("%d %d",&h,&w);
   int a[1002][2];
   a[1][0]=h;
   a[1][1]=w;
   sum=0;
   p=1;
   for(i=2;i<=n;i++)
   {    
	   int f=0;
	   scanf("%d %d",&h1,&w1);
	   for(int j=1;j<=p;j++)
	   { 
		   if((h1<=a[j][0]&&w1<=a[j][1])||(h1<=a[j][1]&&w1<=a[j][0]))
		   {
			   p=p;
			   a[j][0]=h1;
			   a[j][1]=w1;
			   f=1;
			   break;
		   }
	   }
	   if(f==0)
	    {  
		   p+=1;
		   a[p][0]=h1;
		   a[p][1]=w1;
	   }
   }
    printf("%d\n",p);
}