In DSAA, we define \((A[i], A[j])\) in array A as a reverse pair iff \(A[i] > A[j]\) and \(i < j\).
Given two non-descending arrays \(A\) with size \(n\) and \(B\) with size \(m\).
Please return (i) the number of reverse pairs in array \(C=\{A[1], A[2], ..., A[n], B[1], B[2], ..., B[m]\}\);
and (ii) the non-desending arrary \(C\).
If you do not have any idea, please refer to Page 22 (in lecture 3 slides) for inspiration.
The first line contains an integer T(1 ≤ T ≤10), representing the number of test cases.
In each test case:
-
The first line will be two integers \(n\) and \(m\), which are the lengths of the two non decreasing sequences.
-
The second line will be \(n\) integers\(A_1, A_2, ..., A_n\)
-
The third line will be \(m\) integers \(B_1, B_2, ..., B_m\)
For all cases, \(1 <= n, m <= 10^5, 0\leq A_i, B_j\leq 10^9\)
You may need this. Java FastIO template: https://paste.ubuntu.com/p/6ybMcVXvz5/