Last active
August 29, 2015 14:05
-
-
Save mailpraveens/c7391a3f8c417997152e to your computer and use it in GitHub Desktop.
Hackerrank problem from url http://www.hackerearth.com/september-rush/algorithm/game-of-survival/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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