Advertisement
H-a-y-K

Untitled

Apr 20th, 2021
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin >> n;
  10.  
  11.     int *arr = new int[n];
  12.  
  13.     for (int i = 0; i < n; i++)
  14.         std::cin >> arr[i];
  15.  
  16.     int zero_count = 0;
  17.     int max_count = 0;
  18.  
  19.     for (int i = 0; i < n; i++)
  20.     {
  21.         if (arr[i] == 0)
  22.             zero_count++;
  23.         else if (zero_count != 0)
  24.         {
  25.             if (zero_count != 1)
  26.                 if (zero_count > max_count)
  27.                     max_count = zero_count;
  28.  
  29.             zero_count = 0;
  30.         }
  31.     }
  32.  
  33.     cout << max_count;
  34.  
  35.     delete []arr;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement