Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. long long n,i,j,v[1001],temp=1,maxim,poz1,poz2;
  5. int main ()
  6. {
  7. cin>>n;
  8. for (int i=1;i<=n;++i)
  9. {
  10. cin>>v[i];
  11. }
  12. n++;
  13. v[n]=-1;
  14. for (int i=1;i<n;++i)
  15. {
  16. if (v[i]==v[i+1])
  17. temp++;
  18. else
  19. {
  20. //cout<<temp<<" ";
  21. if (temp>maxim)
  22. maxim=temp;
  23. temp=1;
  24. }
  25. }
  26. for (int i=1;i<n+1;++i)
  27. {
  28. if (v[i]==v[i+1])
  29. temp++;
  30. else
  31. {
  32. if (temp==maxim)
  33. poz1=i-temp+1,poz2=i;
  34. temp=1;
  35. }
  36. }
  37. cout<<poz1<<" "<<poz2;
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement