Studds SOLUTIONS SC_02 CODECHEF
A homeroom has a few understudies, half of whom are young men and half of whom are young ladies. You have to orchestrate every one of them in a line for the morning gathering with the end goal that the accompanying conditions are fulfilled:
The understudies must be arranged by non-diminishing stature.
Two young men or two young ladies must not be adjoining one another.
You have been given the statures of the young men in the cluster b and the statures of the young ladies in the exhibit g. See if you can orchestrate them in a request which fulfills the given conditions. Print “YES” in the event that it is conceivable, or “NO” in the event that it isn’t.
For instance, suppose there are n=3 young men and n=3 young ladies, where the young men’s statures are b=[5,3,8] and the young ladies’ statures are g=[2,4,6]. These understudies can be masterminded in the request [g0,b1,g1,b0,g2,b2], which is [2,3,4,5,6,8]. Since this is arranged by non-diminishing tallness, and no two young men or two young ladies are contiguous one another, this fulfills the conditions. Accordingly, the appropriate response is “YES”.
The main line contains a whole number, t, meaning the quantity of experiments.
The primary line of each experiment contains a whole number, n, meaning the quantity of young men and young ladies in the homeroom.
The second line of each experiment contains n space isolated numbers, b1,b2,…bn, meaning the statures of the young men.
The second line of each experiment contains n space isolated numbers, g1,g2,…gn, meaning the statures of the young ladies.
Print precisely t lines. In the ith of them, print a solitary line containing “YES” without cites in the event that it is conceivable to organize the understudies in the ith experiment, or “NO” without cites in the event that it isn’t.
The accompanying course of action would fulfill the given conditions: [b1,g1,b2,g2]. This is on the grounds that the young men and young ladies and isolated, and the stature is in non-diminishing request.