#K41452. Maximum Sum After Optimal Subarray Reversals
Maximum Sum After Optimal Subarray Reversals
Maximum Sum After Optimal Subarray Reversals
You are given t test cases. For each test case, you are provided with two integers n and k on one line followed by an array A of n integers on the next line.
Your task is to compute the maximum possible sum of the array after performing optimal subarray reversals. Under careful observation, you will notice that no matter how you reverse any subarray, the sum can never exceed the sum of all positive numbers in the original array. Hence, the answer for each test case is simply the sum of all positive numbers in the array. (The value k is provided as part of the input but does not affect the result.)
For each test case, output the computed maximum sum on a new line.
Note: All formulas should be written in LaTeX format. For example, the sum of positive numbers can be represented as \(\sum_{x \in A,\; x>0} x\).
inputFormat
The first line contains an integer t denoting the number of test cases. For each test case, there are two lines of input:
- The first line contains two integers n and k, where n is the size of the array and k is an extra parameter.
- The second line contains n space-separated integers representing the elements of the array \(A\).
It is guaranteed that the input is provided via stdin.
outputFormat
For each test case output a single line containing one integer — the maximum possible sum, which is the sum of all positive numbers in the array \(A\), computed as \(\sum_{x \in A,\; x>0} x\).
The output should be printed to stdout.
## sample2
5 3
-1 -2 3 4 -5
4 2
1 2 3 4
7
10
</p>