fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7. while(t--)
  8. {
  9. int n,c=0;
  10. cin >> n;
  11. vector<int> v;
  12. string s;
  13. cin >> s;
  14. for(int i=0;i<n;i++)
  15. {
  16. if(s[i]=='0')
  17. {
  18. c++;
  19. }
  20. else
  21. {
  22. v.push_back(c);
  23. c=0;
  24. }
  25. }
  26. v.push_back(c);
  27.  
  28. vector<int> :: iterator it = max_element(v.begin(),v.end());
  29. cout << *it << endl;
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5324KB
stdin
5
5
1 0 0 1 0
4
0 1 1 1
1
0
3
1 1 1
9
1 0 0 0 1 0 0 0 1
stdout
0
0
1
1
0