So my greedy approach is like,
first step:
sort the elements in A[i] in decreasing order
second step:
a.
to get maximum value, just divide it in half so that elements present in (0 to n/2-1) indexes present in A[i] and elements present in (n/2 to n-1) indexes are move to the B[i] and sort the B[i] in increasing order.
b.
to get minimum value, odd indexes in A[i] and even indexes in B[i].