Need help!! For which test case my code gives WA.
#include
#include
#define fr(start,end,i) for(int i=start;i<=end;++i)
#define revfr(start,end,i) for(int i=start;i>=end;–i)
using namespace std;
struct Dolls {
int w;
int h;
};
typedef struct Dolls Dolls;
Dolls allDolls[20001];
Dolls topDolls[20001];
int n;
bool cmp(Dolls x,Dolls y)
{
if((x.w+x.h)==(y.w+y.h)) return x.w>y.w;
return (x.w+x.h)>(y.w+y.h);
}
main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;cin>>t;
while(t–)
{
cin>>n;
fr(0,n-1,i)
{
cin>>allDolls[i].w>>allDolls[i].h;
}
sort(allDolls,allDolls+n,cmp);
int index=0,found=0;
topDolls[index]=allDolls[0];
fr(1,n-1,i)
{
found=0;
fr(0,index,j)
{
if(allDolls[i].w<topDolls[j].w && allDolls[i].h<topDolls[j].h)
{
topDolls[j]=allDolls[i];
found=1;
break;
}
}
if(found==0)
{
topDolls[++index]=allDolls[i];
}
}
cout<<index+1<<endl;
}
}