#K91617. Leaderboard Calculation
Leaderboard Calculation
Leaderboard Calculation
Given n participants and m problems with corresponding weights, compute the total score for each participant.
The score for the \(i\)-th participant is defined by the equation $$S_i = \sum_{j=1}^{m} w_j\cdot r_{ij},$$ where \(w_j\) is the weight of the \(j\)-th problem and \(r_{ij}\) is either 0 or 1 depending on whether the participant solved the problem.
After computing the scores, sort them in descending order. In case of ties, the participant with the lower original index comes first.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains two integers \(n\) and \(m\) separated by a space.
- The second line contains \(m\) integers, representing the weights \(w_1, w_2, \ldots, w_m\) of the problems.
- The next \(n\) lines each contain \(m\) integers (0 or 1) representing the results of each participant for each problem.
outputFormat
Output a single line to standard output (stdout) containing the sorted scores in descending order, separated by spaces.
## sample3 4
2 3 4 5
1 0 1 0
0 1 1 1
1 1 0 1
12 10 6