You are given an array \(A\) of \(N\) elements where each element is a pair represented by \((X[i], Y[i])\).
Bob and Alice play a game where both of them have to pick some elements from the array \(A\). Suppose, Bob picked the elements at index \(i_1, i_2, ..., i_K\) where \(K \le N\).
- Score(Bob) = \(\sum_\limits{j} (X[j] + Y[j])\), where \(j\) belongs to \((i_1,i_2,....,i_K)\) .
- Score(Alice) = \(\sum_\limits{j} X[j]\), where \(j\) belongs to \((1,2,....,N)\) excluding \((i_1,i_2,....,i_K)\).
Find the minimum number of elements Bob must pick such that the score of Bob is greater than Alice.
Note: \(1\)-based indexing is used.
Input format
- The first line contains an integer \(T\) denoting the number of test cases.
- For each test case:
- The first line contains an integer \(N\).
- The second line contains \(N\) space-separated integers denoting the first element of the pair.
- The third line contains \(N\) space-separated integers denoting the second element of the pair.
Output format
For each test case, print the minimum number of elements Bob needs to pick to score greater than Alice.
Constraints
- If Bob element at index \(4^{th}\).
- Score of Bob = 4 + 3 = 7
- Score of Alice = 3 + 1 + 2 = 6
- Hence, required answer is 1.
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