In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of December 7th
(this exercise will still be available for submission after that deadline, but without couting towards your grade)
[to understand the context of this problem, you should read the class #08 exercise sheet]
After the sticker collection, Alice has now decided to collect Pokemon cards and she is ready to battle with Bob! Each Pokemon card is identified by a positive integer number, representing its "energy". Initially,Alice and Bob have each its own deck of cards. The battle takes place as follows:
Alice doesn't want to lose to Bob and needs your help to find who will win and how many cards they will have.
Given the composition of both Alice and Bob's initial pokemon card decks, your tasks is to simulate the battle and determine who will win the game and how many card will the winner be left with in the end.
The first line of the input contains an integer A, representing the number of cards Alice has in her initial deck. The second line contains A space separated integers Ai, representing the pokemon cards in her deck.
The third line of the input contains an integer B, representing the number of cards Bob has in his initial deck . The fourth line contains B space separated integers Bi, representing the pokemon cards in his deck.
The output should consist of two lines. The first one should be "Alice wins", "Bob wins" or "Tie", indicating who won (or if there was a tie, with the last battle "killing" both remaining cards. The second line should contain a single integer indicating the number of cards left on the winners deck after the battle (this number should be 0 in case of a tie).
The following limits are guaranteed in all the test cases that will be given to your program:
1 ≤ A ≤ 105 | Number of pokemon card in Alice's initial deck | |
1 ≤ Ci ≤ 109 | Initial energy of Alice's cards | |
1 ≤ B ≤ 105 | Number of pokemon card in Bob's initial deck | |
1 ≤ Bi ≤ 109 | Initial energy of Bob's cards |
Example Input 1 | Example Output 1 |
3 400 300 700 4 700 200 500 200 |
Bob wins 2 |
Explanation of Example Input 1:
Bob wins and there are two cards left in his deck at the end:
Example Input 2 | Example Output 2 |
1 200 1 200 |
Tie 0 |