Advertisement
cupsamada

colier 2009 hmm

Jan 29th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 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[30001];
  7. int main()
  8. {
  9. int n, k, x, i, lcr=1, lmax=0;
  10. fin>>n>>k;
  11. for(i=1; i<=n; i++)
  12. {
  13. fin>>v[i];
  14. }
  15. for(i=k+2; i<=n; i++)
  16. {
  17. if(v[i]==v[i-1])
  18. {
  19. lcr++;
  20. }
  21. else
  22. {
  23. if(lmax<lcr)
  24. {
  25. lmax=lcr;
  26. }
  27. lcr=1;
  28. }
  29. }
  30. if(v[n]==v[1])
  31. {
  32. lcr++;
  33. }
  34. for(i=2; i<=k; i++)
  35. {
  36. if(v[i]==v[i-1])
  37. {
  38. lcr++;
  39.  
  40. }
  41. else
  42. {
  43. if(lmax<lcr)
  44. {
  45. lmax=lcr;
  46. }
  47. lcr=0;
  48. }
  49. }
  50. if(lmax<lcr)
  51. {
  52. lmax=lcr;
  53. }
  54. fout<<lmax;
  55. fin.close();
  56. fout.close();
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement