fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int main() {
  5. char a, b;
  6. int d = 0, e = 0, f = 0;
  7. while(cin >> a){
  8. if(a == '0'){
  9. e++;
  10. }
  11. if(b == a && a == '0'){
  12. d++;
  13. f = max({f, d});
  14. }
  15. else{
  16. d = 0;
  17. }
  18. b = a;
  19. }
  20. if(e > 0 && f <= 1){
  21. cout << 1;
  22. }
  23. else if(f == 0 && e == 0){
  24. cout << 0;
  25. }
  26. else{
  27. cout << f + 1;
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5288KB
stdin
0111111000011111

stdout
4