Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- ifstream fin("COLIER.IN");
- ofstream fout("COLIER.OUT");
- int v[30001];
- int main()
- {
- int n, k, x, i, lcr=1, lmax=0;
- fin>>n>>k;
- for(i=1; i<=n; i++)
- {
- fin>>v[i];
- }
- for(i=k+2; i<=n; i++)
- {
- if(v[i]==v[i-1])
- {
- lcr++;
- }
- else
- {
- if(lmax<lcr)
- {
- lmax=lcr;
- }
- lcr=1;
- }
- }
- if(v[n]==v[1])
- {
- lcr++;
- }
- for(i=2; i<=k; i++)
- {
- if(v[i]==v[i-1])
- {
- lcr++;
- }
- else
- {
- if(lmax<lcr)
- {
- lmax=lcr;
- }
- lcr=0;
- }
- }
- if(lmax<lcr)
- {
- lmax=lcr;
- }
- fout<<lmax;
- fin.close();
- fout.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement