Odd Cards
Practice
5 (2 votes)
Algorithms
Sorting
Advanced sorting
Problem
69% Success 236 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

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".

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
7 votes
Tags:
AlgorithmsMedium
Points:30
Tags:
Medium
Points:30
6 votes
Tags:
C++SortingAdvanced SortingAlgorithms