There are \(N\) cards, where \(N = 2k + 1\) is an odd integer \(\geq 3\).
Also, there are two arrays \(A = [a_1, a_2, ... , a_N]\) and \(H = [h_1, h_2, ... , h_N]\).
Here \(a_i\) and \(h_i\) represent the attack point and the health point of the \(i\)th card, respectively.
Assume that Alice choose \(k\) cards first, and then Bob accepts the other \(k + 1\) cards automatically.
Let \(h_a\) and \(h_b\) be the minimal health points of Alice and Bob, respectively.
Suppose that the total power of Alice is obtained by multiplyng \(h_a\) by the sum of the attack points of Alice's cards.
Similarly, the power of Bob is obtained by multiplyng \(h_b\) by the sum of the attack points of his cards.
Then, determine the winner if both players play optimally.
Constraints
- \(1 \leq T \leq 1000\)
- \(3 \leq N \leq 10^5\)
- \(1 \leq a_i \leq 10^5\)
- \(1 \leq h_i \leq 10^5\)
-
\(\)The sum of \(N\) across all test cases does not exceed \(2 \cdot 10 ^ 5\).
Input Format
- The first line contains a single integer \(T\) —- the number of test cases.
- For each testcase:
- The first line contains one odd integer \(N\) —- the length of the arrays.
- The second line contains \(N\) positive integers \(a_1, a_2, ... , a_N\).
-
The third line contains \(N\) positive integers \(h_1, h_2, ... , h_N\).
- The sum of \(n\) over all test cases does not exceed \(2 \cdot 10^5\).
Output Format
- For each testcase, output a single line:
- "Alice" if Alice wins with the optimal play.
- "Bob" if Bob wins with the optimal play.
- Otherwise, output "Tie".
In the first case:
- Alice can choose the \(3\)rd card, and Bob get the other two cards.
- Then the power of Alice is \(3\cdot 3 = 9\), and the power of Bob is \(1 \cdot (1 + 2) = 3\).
- Thus, Alice wins.
In the second case:
- If Alice choose the \(1\)st card, then the power of Alice and Bob are \(1 \cdot3 = 3\) and \(2 \cdot (2 + 1) = 6\), respectively. So Bob wins.
- If Alice choose the \(2\)nd card, then the power of Alice and Bob are \(2 \cdot 2 = 4\) and \(1 \cdot (1 + 3) = 4\), respectively. So they get a tie.
- If Alice choose the \(3\)rd card, then the power of Alice and Bob are \(3 \cdot 1 = 3\) and \(1 \cdot (2 + 3) = 5\), respectively. So Bob wins.
- Since Alice has the right to choose first, she would choose the \(2\)nd card to get a tie.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor