A new fighting game has become popular. There is n number of villains in it, each having some strength. There are n players in the game with each having some energy. The energy is used to kill the villains. A villain can be killed only if the energy of the player is greater than the strength of the villain.
Maxi is playing the game and at a particular time wants to know if it is possible for him to win the game or not with the given set of energies and strengths of players and villains. Maxi wins the game if his players can kill all the villains with the allotted energy.
The first line of input consists of a number of test cases, T.
The first line of each test case consists of a number of villains and player, N.
The second line of each test case consists of the N space-separated by strengths of Villains.
The third line of each test case consists of N space-separated by the energy of players.
1<= T <=10
1<= N <=1000
1<= strength , energy <=100000
For each test case, Print WIN if all villains can be killed else print LOSE in separate lines.
Sample TestCase 1
16112 243 512 343 90 478500 789 234 400 452 150
For the given test case, If we shuffle the players and villains, we can observe that all the villains can be killed by players.
As all the villains can be killed by the players, MAXI will WIN the game. Thus, the final output is to WIN.
How to handle this problem:
So, first, we make a line of code to take input from the user (Such as the number of the test case).
Now, make a variable named count and set as 0.
Then, we will make a result list that stores the result of the input.
Then we will iterate the while loop for checking the number of the test cases.
Then again, we will take the input of the number of players from the user.
Now the next step is to split the input.
Now we will reverse the input of a number of players and villain.
The solution of the problem:
def main(): # First we will take the number of test cases. testCases=int(input())
# Then we will take the count variable for store the value. # And result list for store the answer. count=0 result=[ ] # Now we will run the while loop for take the input according the number of test cases. while testCases>0: # Now we will take the number of player of each team. numberOfPlayer=int(input()) # Then we will take the input of the stregth of both the team. villian=[int(x) for x in raw_input().strip().split()] player=[int(x) for x in raw_input().strip().split()] # Now we Will reverse the strength of the the players. villian.sort(reverse=True) player player.sort(reverse=True) start=0
# Then we will compare the strength of the players. for i in range(numberOfPlayer): for j in range(start,numberOfPlayer) start=0 # Then we will compare the strength of the players. for i in range(numberOfPlayer): for j in range(start,numberOfPlayer): if if player[i]>villian[j]: start=j+1 count+=1 break if (count==numberOfPlayer): result.append("WIN") testCases-=1 else: result.append("LOSE") testCases-=1 count=0 # Then we will print the result. for result in result: print(result) main()