HOTEL BYTELANDIA! What is my mistake?! Gives WA.

//MY CODE
#include
#include<stdio.h>
#include<string.h>
#include
#include<math.h>
#include
#define gc getchar_unlocked()
using namespace std;

void fastin(int &x)
{
register int a=gc;
x=0;
for(;(a<48 || a>57);a=gc);
for(;(a>47 && a<58);a=gc)
x=(x<<1)+(x<<3)+a-48;
}

int main()
{
int t,n,i,j,att,dt;
int ati[105],dp[105],ans,max;
fastin(t);
while(t–)
{ans=0;max=0;
fastin(n);
for(i=0;i<n;i++)
fastin(ati[i]);
for(i=0;i<n;i++)
fastin(dp[i]);

for(i=0;i<n;i++)
{ans=0;
dt=dp[i];
att=ati[i];

    for(j=0;j<n;j++)
    {
    if((ati[j]<dt) && (dp[j]>att))
        {
        if(ati[j]>att)
            att=ati[j];
        if(dp[j]<dt)
            dt=dp[j];
        ans++;
        //cout<<ans<<"a ";

        }
    //cout<<att<<"att "<<dt<<"dt "<<ans<<"a ";
    //cout<<"\n";
    }
    if(ans>max)
        max=ans;

}

printf("%d\n",max);
}

return 0;

}

//