#C11881. Maximum Coding Minutes

    ID: 41246 Type: Default 1000ms 256MiB

Maximum Coding Minutes

Maximum Coding Minutes

An employee is given a list of potential coding sessions with varying durations. Due to work constraints, the employee can attend at most \(L\) sessions in a day. Your task is to determine the maximum number of minutes the employee can code by selecting the sessions with the longest durations.

Given an integer \(N\) representing the total number of available sessions, an integer \(L\) representing the maximum sessions allowed in one day, and a list of \(N\) integers denoting the duration (in minutes) of each session, compute the maximum total duration possible by selecting up to \(L\) sessions. If \(L > N\), simply sum all session durations.

inputFormat

The first line of input contains an integer (T) which denotes the number of test cases. For each test case, the first line contains two integers (N) and (L) separated by a space. The second line contains (N) space-separated integers representing the durations of the sessions.

outputFormat

For each test case, output a single line displaying the maximum total coding minutes that can be achieved by selecting up to (L) sessions.## sample

5
5 3
120 80 140 100 60
4 2
50 40 30 20
6 4
30 30 30 30 10 50
3 2
90 80 70
5 0
10 20 30 40 50
360

90 140 170 0

</p>