#K3451. Maximum Beauty of a Binary Array
Maximum Beauty of a Binary Array
Maximum Beauty of a Binary Array
You are given a binary array A
of length n
. The beauty of this array is defined as the maximum possible length of a contiguous subarray that can be obtained from A
. For this problem, it turns out that the maximum beauty is always equal to n
regardless of the contents of the array.
Your task is to determine and print the maximum beauty for each test case.
Note: The beauty of the array is defined mathematically as \( \max_{subarray} (\text{length of subarray}) \), and since any subarray of a given array of length n
has length at most n
, the answer is always n
.
inputFormat
The first line of input contains an integer T
(1 ≤ T ≤ 104), the number of test cases. Each test case consists of two lines:
- The first line contains an integer
n
(1 ≤ n ≤ 105), the length of the array. - The second line contains
n
space-separated integers, each either0
or1
, representing the binary arrayA
.
It is guaranteed that the sum of all n
over all test cases does not exceed 106.
outputFormat
For each test case, output a single line containing the maximum beauty of the array, which is always equal to n
(the length of the array).
2
5
1 0 1 1 0
4
0 0 1 0
5
4
</p>