Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. int n;
  8. cin>>n;
  9. long x,y,ultima=0;
  10. cin>>x>>y;
  11. long min=abs(x-y);
  12. long xF=x, yF=y;
  13. for (int i=1;i<n-1;i++)
  14. {
  15. cin>>x;
  16. long res=abs(x-y);
  17. if(res<min)
  18. xF=x, yF=y, min=res;
  19. if (res==min)
  20. if (x+y<xF+yF)
  21. xF=x, yF=y, min=res;
  22. y=x;
  23. }
  24.  
  25. cout <<yF << " " << xF;
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement