Prom Night

4.1

158 votes
Algorithms, Approved, Easy, Implementation, Open, Sorting, Two-pointer
Problem

The Hexagon University of India will be hosting its Prom Night tonight.There would be M boys and N girls at the prom tonight. Each boy wants 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 boy.
The third contains N integers each denoting the height of girl.

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

Constraints:
1<=T<=10
1<=N, M<=10000
1<=Height<=200

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?