Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. ifstream fin("distanta.in");
  5. ofstream fout("distanta.out");
  6.  
  7. int dmax=0,poz=0,pozi[100000],pozj[100000],x;
  8.  
  9. int main()
  10. {
  11.  
  12. while(fin>>x)
  13. {
  14. ++poz;
  15. if(pozi[x]==0) pozi[x]=poz;
  16. else {pozj[x]=poz;
  17. if(pozj[x]-pozi[x]>dmax) dmax=pozj[x]-pozi[x];}
  18.  
  19.  
  20. }
  21.  
  22. fout<<dmax;
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement