fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t; cin>>t;
  7. while(t--)
  8. {
  9. int n,b=0; cin>>n;
  10. int arr[n];
  11. for(int i=0;i<n;i++)
  12. cin>>arr[n];
  13. for(int i=0;i<n;i++)
  14. {
  15. int a=0;
  16. while(arr[i]!=0)
  17. {
  18. a++;
  19. i++;
  20.  
  21. }
  22. if(a>b)
  23. b=a;
  24. i++;
  25. }
  26. cout<<b<<endl;
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 16064KB
stdin
3
6
1 0 2 3 0 4
1
0
3
1 0 1
stdout
9
1
6