Result: Accepted
Time: 4ms
Memory: 1764kB
#include <cstdio>
#include <iostream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int t,n;
struct node
{
int len,wid;
}aa[1010];
int main()
{
cin>>t;
int a,b;
int cnt=0;
memset(aa,0,sizeof aa);
for(int i=0;i<t;i++)
{
cin>>a>>b;
int flag=0;
if(i==0)
{
flag=1;
}
else{
for(int i=1;i<=cnt;i++)
{
if((aa[i].len>=a&&aa[i].wid>=b))
{
aa[i].len=a;aa[i].wid=b;
break;
}
else if(aa[i].wid>=a&&aa[i].len>=b)
{
aa[i].len=b;aa[i].wid=a;
break;
}
else if(i==cnt)
flag=1;
}
}
if(flag)
{
cnt++;
aa[cnt].len=a;
aa[cnt].wid=b;
}
}
cout<<cnt<<endl;
}