#K82887. Maximum Target Score

    ID: 36075 Type: Default 1000ms 256MiB

Maximum Target Score

Maximum Target Score

You are given a series of test cases. In each test case, there are N targets with associated point values. A player is allowed to hit at most K targets. The objective is to maximize the score by choosing the highest scoring targets.

For each test case, calculate the sum of the K highest point values among the N targets. Formally, if the targets' points are sorted in descending order as \(p_1, p_2, \dots, p_N\), then the maximum score is:

\(\sum_{i=1}^{K} p_i\)

Output the result for each test case in the format "Case X: Y", where X is the test case number (starting at 1) and Y is the maximum score computed.

inputFormat

The input is read from stdin and has the following format:

  • An integer T representing the number of test cases.
  • For each test case:
    • A line containing two integers N and K, where N is the number of targets and K is the maximum number of targets that can be hit.
    • A line containing N space-separated integers representing the points assigned to each target.

outputFormat

For each test case, print a line on stdout in the format:

Case X: Y

where X is the test case number (starting from 1) and Y is the maximum score by summing the top K points.

## sample
2
5 2
1 2 3 4 5
6 3
10 3 2 7 5 1
Case 1: 9

Case 2: 22

</p>