Advertisement
nicuvlad76

Untitled

Jan 13th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ///523
  4. int n, x,y, lc, lmax, st, dr;
  5. int main()
  6. {
  7. int i,j;
  8. cin>>n;
  9. cin>>x;
  10. lc=1;
  11. for(i=2; i<=n; i++)
  12. {
  13. cin>>y;
  14. if(x==y) lc++;
  15. else ///am terminat o secv de valori egale
  16. {
  17. if(lc>=lmax)
  18. {
  19. lmax=lc;
  20. dr=i-1;
  21. st=i-lc;
  22. }
  23. x=y;
  24. lc=1;///incep o alta secv
  25. }
  26. }
  27. if(lc>=lmax)///ultima secventa
  28. {
  29. lmax=lc;
  30. dr=i-1;
  31. st=i-lc;
  32. }
  33. cout<<st<<" "<<dr;
  34. return 0;
  35. }
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement