Advertisement
a53

SecvEgale1_v2

a53
Jun 29th, 2021
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int n, fr1[1000001], nr;
  5. int lmax, r1, r2, l;
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11. cin>>n;
  12. for(int i=1; i<=n; ++i)
  13. {
  14. cin>>nr;
  15. if(!fr1[nr])
  16. fr1[nr]=i;
  17. else
  18. {
  19. l=i-fr1[nr]+1;
  20. if(l>lmax)
  21. {
  22. lmax=l;
  23. r1=fr1[nr];
  24. r2=i;
  25. }
  26. }
  27.  
  28. }
  29. cout<<r1<<" "<<r2;
  30. return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement