fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main() {
  7. pair<int, int> nr[100001];
  8. int mx = 0;
  9. ifstream fin("distanta.in");
  10. ofstream fout("distanta.out");
  11. int n = 0;
  12. while(cin >> nr[n].first) {
  13. nr[n++].second = n;
  14. }
  15. sort(nr, nr + 1);
  16. for(int i = 0; i < n; i++) {
  17. int j = i + 1;
  18. while(nr[i].first == nr[j].first) {
  19. mx = max(mx, nr[j].second - nr[i].second);
  20. j++;
  21. }
  22. }
  23. cout << mx;
  24. }
  25.  
Success #stdin #stdout 0.01s 5276KB
stdin
30 33 16 33 37 16 72 65 16 46
stdout
Standard output is empty