You are given two arrays AA and BB of size NN. We define a pair as (Ai(Ai, Bi)Bi) where 0≤i≤N−10≤i≤N−1.
The task is to sort these pairs in decreasing order of the second elements of the pairs i.e BiBi. If both the second elements are equal sort according to increasing order of the first elements of the pairs.
Output the sorted pairs in a single line with a space separating the pairs. Each pair is printed with first element followed by a space and second element. See Explanation Section for better understanding.
Input:
- First line will contain a single integer NN.
- Second line contains NN space separated integers A0A0, A1A1, ...… AN−1AN−1 denoting the elements of array AA.
- Third line contains NN space separated integers B0B0, B1B1, ...… BN−1BN−1 denoting the elements of array BB.
Output:
Output in a single line 2∗N2∗N space separated integers. Output the pairs in sorted order, where the first element of a pair is from AjAj and second element is from BjBj with a space in between.
Constraints
- 1≤N≤1051≤N≤105
- 1≤Ai,Bi≤10181≤Ai,Bi≤1018
Subtasks
- 30 points : 1≤N≤10001≤N≤1000
- 70 points : Original constraints
Sample Input:
3
2 2 3
6 3 3
Sample Output:
2 6 2 3 3 3
listt
CREATE AN ACCOUNT TO GET NOTIFICATIONS ABOUT
NEW QUESTIONS AND ANSWERS.
DOWNLOAD ATTACHMENT FOR ANSWER: