Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MaxN = 1001;
  5.  
  6. int main()
  7. {
  8. int a[MaxN], n;
  9. int st, dr, lmax = 0;
  10.  
  11. cin >> n;
  12.  
  13. for (int i = 1; i <= n; ++i)
  14. cin >> a[i];
  15.  
  16. int cnt = 1, poz;
  17. for (int i = 1; i <= n; ++i)
  18. {
  19. if (a[i] == a[i + 1])
  20. {
  21. if (cnt == 1)
  22. poz = i;
  23.  
  24. cnt++;
  25. }
  26. else
  27. {
  28. if (cnt >= lmax)
  29. {
  30. lmax = cnt;
  31. st = poz;
  32. dr = poz + cnt - 1;
  33. }
  34. cnt = 1;
  35. }
  36. }
  37.  
  38. cout << st << ' ' << dr;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement