#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#include<vector>
int main() {
// your code goes here
vector<int>arr1={1,2,3,4,5};
vector<int>arr2={800,1000,1500,1550,1800};
int target=1100;
int a,b,sum;
int closest_sum=INT_MAX;
long long answer=-10000000000000;
int right=arr2.size()-1;
int left;
while(left<arr1.size() && right>=0) // or while(left<arr1.size() && right>=0)
{
sum=arr1[left]+arr2[right];
if(sum>target)
{
right--;
}
else if(sum<=target)
{
if(sum>answer)
{
answer=sum;
a=arr1[left];
b=arr2[right];
}
left++;
}
}
cout<<a<<" "<<b;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGU8dmVjdG9yPgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCQoJdmVjdG9yPGludD5hcnIxPXsxLDIsMyw0LDV9OwoJdmVjdG9yPGludD5hcnIyPXs4MDAsMTAwMCwxNTAwLDE1NTAsMTgwMH07CglpbnQgdGFyZ2V0PTExMDA7CglpbnQgYSxiLHN1bTsKCWludCBjbG9zZXN0X3N1bT1JTlRfTUFYOwoJbG9uZyBsb25nIGFuc3dlcj0tMTAwMDAwMDAwMDAwMDA7CiAgICBpbnQgcmlnaHQ9YXJyMi5zaXplKCktMTsKICAgIGludCBsZWZ0OwogICAgIHdoaWxlKGxlZnQ8YXJyMS5zaXplKCkgJiYgcmlnaHQ+PTApIC8vIG9yIHdoaWxlKGxlZnQ8YXJyMS5zaXplKCkgJiYgcmlnaHQ+PTApCiAgICAgIHsKICAgICAgCXN1bT1hcnIxW2xlZnRdK2FycjJbcmlnaHRdOwogICAgICAgaWYoc3VtPnRhcmdldCkKICAgICAgICB7CiAgICAgICAgCXJpZ2h0LS07CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYoc3VtPD10YXJnZXQpIAogICAgICAgICB7CiAgICAgICAgIAlpZihzdW0+YW5zd2VyKQogICAgICAgICAJICB7CiAgICAgICAgIAkgIAlhbnN3ZXI9c3VtOwogICAgICAgICAJICAJYT1hcnIxW2xlZnRdOwogICAgICAgICAJICAJYj1hcnIyW3JpZ2h0XTsKICAgICAgICAgCSAgfQogICAgICAgICAJICBsZWZ0Kys7CiAgICAgICAgIH0KICAgICB9CiAgICAgCiAgICAgY291dDw8YTw8IiAiPDxiOwoJCglyZXR1cm4gMDsKfQ==