Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ///523
- int n, x,y, lc, lmax, st, dr;
- int main()
- {
- int i,j;
- cin>>n;
- cin>>x;
- lc=1;
- for(i=2; i<=n; i++)
- {
- cin>>y;
- if(x==y) lc++;
- else ///am terminat o secv de valori egale
- {
- if(lc>=lmax)
- {
- lmax=lc;
- dr=i-1;
- st=i-lc;
- }
- x=y;
- lc=1;///incep o alta secv
- }
- }
- if(lc>=lmax)///ultima secventa
- {
- lmax=lc;
- dr=i-1;
- st=i-lc;
- }
- cout<<st<<" "<<dr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement