Perfect subarray

Perfect subarray

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Time Limit: 2.0 s

Memory Limit: 256.0 MB

Description

A subarray is called perfect if it

  • starts with 1
  • ends with 3
  • do not contain 2

Alice has an array of length \(N\). He wants to find the longest subarray from his array that is perfect.
Can you help alice in this task ?

A subarray is a contigious part of the array. for example {1} {2} {3} {1,2} {2,3} {1,2,3} each are the valid subarrays of the array {1,2,3) while {1,3} is not a valid subarray.

Input

First line takes in an integer \(T\) : number of testcases
in each testcase
first line takes an integer \(N\) : size of the array
second line takes \(N\) integers : the elements of the array
1 <= \(T\) <= 100
1 <= \(N\) <= 100000
1 <= \(Ai\) <= 10
sum of N over all testcase will not exceed 10^5

Output

print \(T\) integer in each line : the maximum length of a perfect subarray

Sample

Input Output
2
8
1 1 2 5 3 1 8 3
5
1 1 3 3 2
3
4

in testcase 1, the longest perfect subarray is {1 8 3}
the subarray {1,1,2,5,3} is not valid because it contains 2

in testcase 2 , the longest perfect subarray is 1 1 3 3

Brain booster #2

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
11
Start at
2024-03-06 13:00
End at
2024-03-06 17:00
Duration
4.0 hour(s)
Host
Partic.
49