COOLING:WA. CANT GET WHATS WRONG.

#include
#include

 int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}

int main () {

  int num,i;
 int t;
 scanf("%d",&t);
 while(t--){
scanf("%d",&num);
    int a[num];
    int b[num];

 for(i=0;i<num;i++)
 {
  scanf("%d",&a[i]);
 }

  qsort (a, num, sizeof(int), compare);


 for(i=0;i<num;i++)
 {
  scanf("%d",&b[i]);
 }

  qsort (b, num, sizeof(int), compare);

  int j=0;int count=0;
  for (i=0; i<num&&j<num; i++)
  {   if(a[i]>b[j])
        {
        j++;
        if(j==num)
            break;
        }
        if(a[i]<=b[j])
        {
            count++;
            j++;
            if(j==num)
                break;
        }
    }
    printf("%d\n",count);
 }
  return 0;
}

it fails for this test case
3
3 4 5
1 2 3
hint:replace the if(a[i]>b[j]) statement with while(a[i]>b[j])

1 Like