Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int MaxN = 1001;
- int main()
- {
- int a[MaxN], n;
- int st, dr, lmax = 0;
- cin >> n;
- for (int i = 1; i <= n; ++i)
- cin >> a[i];
- int cnt = 1, poz;
- for (int i = 1; i <= n; ++i)
- {
- if (a[i] == a[i + 1])
- {
- if (cnt == 1)
- poz = i;
- cnt++;
- }
- else
- {
- if (cnt >= lmax)
- {
- lmax = cnt;
- st = poz;
- dr = poz + cnt - 1;
- }
- cnt = 1;
- }
- }
- cout << st << ' ' << dr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement