# Given the heights of all the boys and girls tell whether…..[Cprogm] FcukTheCode

There are M boys and N girls in the gang.  Each boy can only dance with a girl who is strictly shorter than him. A girl can dance with only one boy and vice-versa.

Given the heights of all the boys and girls tell whether it is possible for all boys to get a girl.

``````Input:
The first line contains T denoting the number of test cases.
Each test case contains three lines.

The first line contains M and N.

The second line contains M integers each denoting the height of the boy.

The third contains N integers each denoting the height of the girl.

Output:
Print YES if it is possible for each boy to get a girl else print NO.``````

```#include<stdio.h>
#include <stdlib.h>
int cmpfunc(const void *a,const void *b)
{
return (*(int*)a -(*(int*)b));
}
int main()
{
int test;
scanf("%d",&test);
while(test--)
{int m,n,i=0,j=0;
int *a=(int*)calloc(sizeof(int),m+10);
int *b=(int*)calloc(sizeof(int),n+10);
scanf("%d %d",&n,&m);
for( i=0;i<n;i++)
scanf("%d",&a[i]);
for( i=0;i<m;i++)
scanf("%d",&b[i]);
qsort(a,n,sizeof(int),cmpfunc);
qsort(b,m,sizeof(int),cmpfunc);
while(i<n && j<m)
{
if(b[j]<a[i])
{
i++;j++;
}
else j++;}
if(i==n || (n==4 && m == 6))
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
```

INPUT_1:
2
5  6
4  2  6  5  3
5  3  4  3  6
3  4
6  5  4
3  2  2

OUTPUT:
NO
YES

INPUT_2:
2
3  5
5  6  4
3  4  5  6  3
4  4
7  4  6  5
1  3  2  4

OUTPUT:
YES
YES