#K56637. Longest Maximum Sum Subsequence Length

    ID: 30243 Type: Default 1000ms 256MiB

Longest Maximum Sum Subsequence Length

Longest Maximum Sum Subsequence Length

Given a sequence of integers, your task is to determine the length of a subsequence that produces the maximum possible sum. The subsequence is formed by selecting any of the positive integers from the given sequence. In other words, the maximum sum is achieved by summing all positive numbers in the sequence. If no positive number exists, the maximum sum is 0, and the length of such subsequence is defined to be 0.

Formally, for a sequence \(b_1, b_2, \dots, b_M\), the maximum sum is \(S=\sum_{i: b_i>0} b_i\), and the answer is the count of such \(b_i\) (i.e. \(\#\{i \mid b_i >0\}\)).

You are given \(T\) test cases. For each test case:

  • The first number indicates the number of elements, \(M\).
  • The following \(M\) integers form the sequence \(b\).

Print the result for each test case on a new line.

inputFormat

The input is read from stdin and has the following format:

T
M1 b11 b12 ... b1M1
M2 b21 b22 ... b2M2
...
MT bT1 bT2 ... bTM_T

Here:

  • T is the number of test cases.
  • For each test case, the first integer \(M\) denotes the number of elements in the sequence.
  • The next \(M\) integers represent the sequence elements.

outputFormat

For each test case, output a single integer representing the length of the longest subsequence that gives the maximum possible sum. Each result should be printed on a new line to stdout.

## sample
2
5 1 -2 3 4 5
6 -1 -2 -3 -4 -5 -6
4

0

</p>