시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 13 | 3 | 2 | 66.667% |
We call a sequence of numbers balanced, if the amount of positive values in the sequence equals the amount of negative values.
The first line of the input contains an integer T, 1 ≤ T ≤ 15, indicating the number of test cases.
For each test case, two lines appear. The first line contains an integer N, 0 ≤ N ≤ 100000. The second line contains N non-zero 32-bit signed integers.
For each test case, the output contains a line in the format Case #x: M, where x is the case number (starting from 1) and M is the length of the Longest Balanced Sub-Sequence (LBSS) of consecutive elements.
2 8 -1 -5 1 -7 8 -6 -9 -2 17 5 -2 1 3 7 9 -9 -1 6 -7 -1 2 8 3 1 -2 -1
Case #1: 4 Case #2: 12
For the first test case, the LBSS is sub-sequence (-5 1 -7 8) or (1 -7 8 -6); both with two positive and two negative values.
For the second test case, the LBSS is sub-sequence (9 -9 -1 6 -7 -1 2 8 3 1 -2 -1) with six positive and six negative values.