Advertisement
Josif_tepe

Untitled

Jan 13th, 2022
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <queue>
  5. using namespace std;
  6. int main() {
  7.     int n;
  8.     cin >> n;
  9.     vector<int> v(n);
  10.     for(int i =0 ; i < n; i++) {
  11.         cin >> v[i];
  12.     }
  13.     int consecutive = 0, result = 0;
  14.     for(int i = 0; i < n; i++) {
  15.         if(v[i] == 1) {
  16.             consecutive++;
  17.         }
  18.         else {
  19.             result = max(result, consecutive);
  20.             consecutive = 0;
  21.         }
  22.         result = max(result, consecutive);
  23.     }
  24.     cout << result << endl;
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement