Lexicographically largest array

0

0 votes
Divide-and-conquer algorithm, Sorting, Algorithms
Problem

Sample Input
5 3
1 2 3 4 5
1 3 4 2
2 1 2 3
1 4 5 -6
Sample Output
3 3 5 0 -1
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Editor Image

?