denis_andrei10

secv

Jan 30th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. ifstream fin("COLIER.IN");
  5. ofstream fout("COLIER.OUT");
  6. int v[1005];
  7. int main()
  8. {
  9.     int n, k, lcrt=1, lmax=0, i, g;
  10.     fin>>n>>k;
  11.     g=k;
  12.     for(i=1; i<=n; i++)
  13.     {
  14.         fin>>v[i];
  15.  
  16.     }
  17.     for(i=k+2; i<=n; i++)
  18.     {
  19.             if(v[i]==v[i-1])
  20.  
  21.             {
  22.                 lcrt++;
  23.             }
  24.             else
  25.             {
  26.                 if(lcrt>lmax)
  27.                 {
  28.                     lmax=lcrt;
  29.                 }
  30.                 lcrt=1;
  31.             }
  32.     }
  33.     if(v[n]==v[1])
  34.     {
  35.         lcrt++;
  36.     }
  37.     else
  38.     {
  39.         lcrt=1;
  40.     }
  41.     for(i=2; i<=k; i++)
  42.     {
  43.          if(v[i]==v[i-1])
  44.             {
  45.                 lcrt++;
  46.             }
  47.             else
  48.             {
  49.                 if(lcrt>lmax)
  50.                 {
  51.                     lmax=lcrt;
  52.                 }
  53.                 lcrt=1;
  54.             }
  55.     }
  56.     if(lcrt>lmax)
  57.     {
  58.         lmax=lcrt;
  59.     }
  60.     fout<<lmax;
  61.     return 0;
  62. }
Add Comment
Please, Sign In to add comment