Advertisement
Josif_tepe

Untitled

Mar 3rd, 2023
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. #include <map>
  5. #include <cstring>
  6. #include <algorithm>
  7. #include <stack>
  8. #include <queue>
  9. #include <fstream>
  10. using namespace std;
  11.  
  12. typedef long long ll;
  13.  
  14.  
  15. int main() {
  16.     int n;
  17.     cin >> n;
  18.    
  19.     int niza[n];
  20.     for(int i = 0; i < n; i++) {
  21.         cin >> niza[i];
  22.     }
  23.    
  24.     int najgolem = 0;
  25.     for(int i = 0; i < n; i++) {
  26.         int broj_na_trojki = 0;
  27.         for(int j = i; j < n; j++) {
  28.             if(niza[j] == 3) {
  29.                 broj_na_trojki++;
  30.             }
  31.             if(broj_na_trojki == 3) {
  32.                 if(najgolem < j - i) {
  33.                     najgolem = j - i;
  34.                 }
  35.             }
  36.         }
  37.     }
  38.     cout << najgolem + 1 << endl;
  39.     return 0;
  40. }
  41. /*
  42.  
  43.  **/
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement