Advertisement
Josif_tepe

Untitled

Feb 22nd, 2024
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int N;
  8.     cin >> N;
  9.  
  10.     int a[N];
  11.  
  12.     vector<int> v;
  13.  
  14.     for (int i = 0; i < N; i++)
  15.     {
  16.         cin >> a[i];
  17.         if (a[i] == 3)
  18.             v.push_back(i + 1);
  19.     }
  20.  
  21.     v.push_back(N + 1);
  22.  
  23.     int MAX = 0;
  24.     for (int i = 0; i <= v.size() - 5; i++)
  25.         MAX = max(MAX, v[i + 4] - v[i] - 1);
  26.  
  27.     cout << MAX;
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement