Skip to content

Instantly share code, notes, and snippets.

@mailpraveens
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mailpraveens/c7391a3f8c417997152e to your computer and use it in GitHub Desktop.
Save mailpraveens/c7391a3f8c417997152e to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
#include <stdlib.h> /* qsort */
int compare (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
int main()
{
int testcases;
cin >> testcases;
while(testcases > 0){
int n;
cin >> n;
int anistrength[n];
int swordPower[n];
for(int i = 0; i < n ; i++){
cin >> swordPower[i];
}
for(int i = 0; i < n ; i++){
cin >> anistrength[i];
}
qsort (anistrength, n, sizeof(int), compare);
qsort (swordPower, n, sizeof(int), compare);
int k=0;
for(k = 0; k < n; k++){
if(swordPower[k] < anistrength[k]) {
cout<<"NO"<<endl;
break;
}
}
if(k == n){
cout<<"YES"<<endl;
}
testcases--;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment