Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int n;
- cin>>n;
- long x,y,ultima=0;
- cin>>x>>y;
- long min=abs(x-y);
- long xF=x, yF=y;
- for (int i=1;i<n-1;i++)
- {
- cin>>x;
- long res=abs(x-y);
- if(res<min)
- xF=x, yF=y, min=res;
- if (res==min)
- if (x+y<xF+yF)
- xF=x, yF=y, min=res;
- y=x;
- }
- cout <<yF << " " << xF;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement