Advertisement
rotti321

Cea mai lunga secv para din sir [cea mai din drp]]

Mar 21st, 2022
702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     ifstream cin("test.in");
  7. //  ofstream cout("test.out");
  8.  
  9.     int n,m,a[101],lung=1,lmax=0,pozST,pozDR;
  10.     cin>>n;
  11.     for (int i=1; i<=n; i++)
  12.     {
  13.         cin>>a[i];
  14.     }
  15.     for (int i=1; i<=n-1; i++)
  16.     {
  17.         if (a[i]%2==0 && a[i+1]%2==0)
  18.         {
  19.             lung++;
  20.         }
  21.         else
  22.         {
  23.             lung=1;
  24.         }
  25.         if (lung>=lmax)
  26.         {
  27.             lmax=lung;///lung = pozDR - pozST +1
  28.             pozDR = i+1;
  29.             pozST = pozDR - lung +1;
  30.         }
  31.     }
  32.     cout<<lmax<<" "<<pozST<<" "<<pozDR;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement