输入样例:
4
5
1 0 1 0 1
6
0 1 0 1 1 0
7
1 0 1 1 1 0 1
3
0 0 0
输出样例:
2
2
3
0
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 400010;
vector<int> a(N);
int main()
{
int t,n;
cin >> t;
while(t--)
{
cin >> n;
int cnt=0;
int maxx=-1;
for (int i = 0; i < n; i ++ )
{
scanf("%d", &a[i]);
a[n+i]=a[i];
}
for (int i = 0; i < 2*n; i ++ ){
if(a[i]){
cnt++;
}else{
cnt=0;
}
maxx = max(cnt,maxx);
}
cout <<maxx << endl;
}
return 0;
}