3 Point Shot
Max is watching a basketball game of team A versus team B (creative names, I know). He measures the distances when either team makes a successful shot. A successful shot is worth either 2 or 3 points, depending on the distance it was made from. A shot is worth 2 points if the distance it was made from, \(x\), does not exceed \(d\) meters (\(x \leq d\)), and a throw is worth 3 points if the distance exceeds \(d\) meters (\(x > d\)). \(d\) is a non-negative integer (\(d \geq 0\)).
Max loves team A. Please help Max pick a \(d\) such that the advantage of points scored by team A is maximised. The advantage of points scored by the team A is defined as the score of team A subtract the score of team B.
The first line contains an integer \(N\), the number of successful shots performed by team A. Following this line, there are \(N\) space separated integers, the distances for each throw (\(a_i\)).
The next line contains an integer \(M\), the number of successful shots performed by team B. Following this line, there are \(M\) space separated integers, the distances for each throw (\(b_i\)).
- \(1 \leq N, M \leq 10^5\)
- \(1 \leq a_i, b_i \leq 2\times 10^9\)
On a single line, print two integers: \(a\) and \(b\) separated by a space. \(a\) denotes score of team A and \(b\) denotes the score of team B. \(a - b\) should be as large as possible.
If there are multiple solutions, print the one where \(a\) is maximum.
3 1 2 3 2 5 6