#K71. Compute Student Merit
Compute Student Merit
Compute Student Merit
You are given two lists of integers, \(X\) and \(Y\), each of length \(N\). For each student \(i\), their overall merit is defined as \(X_i - Y_i\). Your task is to compute the overall merit for each student and then output a list of pairs \((i, M)\) sorted in descending order of \(M\) (the computed merit). In case of ties, the student with the smaller index should come first.
More formally, for each valid \(i\), compute the merit as:
[ M_i = X_i - Y_i ]
Your output should contain the pairs \((i, M_i)\) in a single line for each test case, with each pair represented by the index and the merit separated by a space. Different pairs in the same test case should be separated by a space. The input consists of multiple test cases.
Example:
Input: 2 3 50 60 70 5 10 15 4 20 40 30 35 10 15 25 5</p>Output: 2 55 1 50 0 45 3 30 1 25 0 10 2 5
inputFormat
The first line of input contains an integer \(T\) representing the number of test cases. For each test case:
- The first line contains an integer \(N\), the number of students.
- The second line contains \(N\) integers representing the list \(X\).
- The third line contains \(N\) integers representing the list \(Y\).
All input should be read from standard input (stdin).
outputFormat
For each test case, output a single line containing the computed pairs \((i, M_i)\) in sorted order, where each pair is represented by the student index and the corresponding merit. The pairs should be space-separated. Output to standard output (stdout).
For instance, if the computed sorted pairs are \((2, 55)\), \((1, 50)\), and \((0, 45)\), you should output:
2 55 1 50 0 45## sample
2
3
50 60 70
5 10 15
4
20 40 30 35
10 15 25 5
2 55 1 50 0 45
3 30 1 25 0 10 2 5
</p>