Question: Please use C++. 9.2 Programming Assignment #2 Sorting Riverfield Country Day School will be hosting its Prom Night tonight.There would be M boys and N
Please use C++.
9.2 Programming Assignment #2
Sorting
Riverfield Country Day School will be hosting its Prom Night tonight.There would be M boys and N girls at the prom tonight. Each boy wants to 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 dance with 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 dance with a girl else print NO.
Sample input:
1 4 5 2 5 6 8 3 8 5 1 7
Output from sample input:
YES
THE FOLLOWING SOLUTION DOES NOT WORK,
#include
int main() { int t; cin >> t; /umber of tests while(t--){ //loop for each test int m, n; cin >> m >> n; //read number of boys and girls
vector
for(int i = 0; i > boys[i];
for(int i = 0; i > girls[i];
sort(boys.begin(), boys.end()); //sort heights of boys sort(girls.begin(), girls.end()); //sort heights of girls
//match first least heighted boy with first least heighted girl if girls[0]
int b = 0, g = 0; while(b


That's what happens when I try to run the following code in "Zybooks."
g++: fatal error: Killed signal terminated program cclplus compilation terminated. Program end never reached (commonly due to an infinite loop or infinite recursion)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
