#K2871. Maximum Coins Collection
Maximum Coins Collection
Maximum Coins Collection
You are given a platform game scenario where a rider collects coins. In each test case, you are provided with two integers \(N\) and \(M\), where \(N\) represents the total number of platforms and \(M\) represents the number of moves that the rider can make. The rider collects coins from the platforms sequentially starting from the first platform.
The rule is simple:
If \(M \geq N\), the rider collects coins from all \(N\) platforms. Otherwise, the rider collects coins from the first \(M\) platforms.
Thus, the maximum number of coins collected can be computed as \(S = \sum_{i=1}^{k} c_i\), where \(k = \min(N, M)\) and \(c_i\) is the number of coins on the \(i^{th}\) platform.
Your task is to determine the maximum coins the rider can collect for each test case.
inputFormat
The first line of input contains an integer \(T\) denoting the number of test cases. Each test case consists of two lines:
- The first line contains two space-separated integers \(N\) and \(M\) representing the number of platforms and the number of moves, respectively.
- The second line contains \(N\) space-separated integers where each integer represents the number of coins on that platform.
outputFormat
For each test case, output a single integer which is the maximum number of coins the rider can collect. Each answer should be printed on a new line.
## sample5 3
1 2 3 4 5
6