#C4355. Optimize Bus Passenger Allocation

    ID: 47884 Type: Default 1000ms 256MiB

Optimize Bus Passenger Allocation

Optimize Bus Passenger Allocation

You are given several test cases. In each test case, there are N buses and a number M indicating how many buses must be fully occupied. Each bus has a certain capacity. To follow the bus full occupancy rule, exactly M buses will be completely filled with passengers, and the remaining buses can be partially filled. The total number of passengers that can be served is simply the sum of the capacities of all buses.

You are required to compute, for each test case, the maximum number of passengers that can be served. Mathematically, if the capacities are given by \(a_1, a_2, \dots, a_N\), then the answer is:

\(\sum_{i=1}^{N} a_i\)

Note that although the value of M is provided and used for illustrative purposes, the optimal strategy in this problem is to utilize the full capacity of each bus.

inputFormat

The input is given via standard input (stdin) and has the following format:

T
N1 M1
capacity1 capacity2 ... capacityN1
N2 M2
capacity1 capacity2 ... capacityN2
...
NT MT
capacity1 capacity2 ... capacityNT

The first line contains an integer T, the number of test cases. For each test case, the first line contains two integers N and M, where N is the number of buses and M is the number of buses that must be fully occupied. The next line contains N space-separated integers representing the capacity of each bus.

outputFormat

For each test case, output a single line in the format:

Case #x: y

Where x is the test case number (starting from 1) and y is the maximum number of passengers that can be served. The output should be written to standard output (stdout).

## sample
2
5 2
10 20 30 40 50
3 1
15 25 35
Case #1: 150

Case #2: 75

</p>