#K75892. Maximum Possible Sum
Maximum Possible Sum
Maximum Possible Sum
You are given an array of integers. Your task is to compute the maximum possible sum of its elements by replacing any negative integers with zero. In other words, you must sum up only the positive integers in the array.
Formally, given an array \(A = [a_1, a_2, \dots, a_n]\), you need to compute the value:
\(\sum_{i=1}^{n} \max(a_i, 0)\)
This problem is simple but tests your ability to process input data and implement basic array operations.
inputFormat
The input is given via standard input (stdin). The first line contains an integer (t) denoting the number of test cases. Each test case consists of two lines. The first line contains an integer (n), the number of elements in the array. The second line contains (n) space-separated integers which represent the array.
outputFormat
For each test case, output a single line on standard output (stdout) containing the maximum possible sum, which is the sum of all positive integers in the given array.## sample
1
4
-2 0 1 3
4
</p>