#K15926. Sum of Top K Developers' Scores
Sum of Top K Developers' Scores
Sum of Top K Developers' Scores
You are given (M) teams, each containing a list of developers' proficiency scores. For each team, your task is to calculate the sum of the top (K) scores. If a team has fewer than (K) scores, sum all available scores.
The input is provided via standard input (stdin) and the output should be printed to standard output (stdout). Ensure that your solution works efficiently for all provided test cases.
inputFormat
The first line contains two space-separated integers (M) and (K), where (M) is the number of teams and (K) is the number of top scores to consider for each team.
Each of the following (M) lines describes a team: the line starts with an integer (N_i) representing the number of scores in that team, followed by (N_i) space-separated integers representing the scores.
outputFormat
Output (M) lines where each line contains a single integer representing the sum of the top (K) scores for the corresponding team.## sample
3 2
4 3 5 1 7
2 2 8
3 4 6 1
12
10
10
</p>