CodeChef::SC_02
#include <bits/stdc++.h>
using namespace std ;
#define boost ios::sync_with_stdio(false);cin.tie(0)
int main (){
int t ;
cin >> t ;
while (t--){
int n ;
cin >> n ;
int boys[n];
int girls[n];
for (int i = 0; i < n; ++i) {
cin >> boys[i];
}
for (int i = 0; i < n; ++i) {
cin >> girls[i];
}
sort(boys,boys+n) ;
sort(girls,girls+n) ;
bool checker{false};
for (int i = 1; i < n; ++i) {
if(boys[0] > girls[0] and boys[i] > girls[i]){
checker = true ;
}
else if (girls[0] > boys[0] and girls[i] > boys[i]){
checker = true ;
}
else{
checker = false ;
break;
}
}
if (checker){
cout << "YES" << '\n' ;
}
else{
cout << "NO" << '\n' ;
}
}
return 0 ;
}
Comments
Post a Comment