problem
solution
codes
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
const int maxn = 100010;
int n, a[maxn], b[maxn];
priority_queue<int>q;
void print(){
if(q.empty())return ;
int t = q.top(); q.pop();
print();
cout<<t<<" ";
}
int main(){
cin>>n;
for(int i = 1; i <= n; i++)cin>>a[i];
for(int i = 1; i <= n; i++)cin>>b[i];
sort(a+1,a+n+1);
sort(b+1,b+n+1);
for(int i = 1; i <= n; i++){
q.push(a[1]+b[i]);
}
for(int i = 2; i <= n; i++){
if(a[i]+b[1]>=q.top())break;
for(int j = 1; j <= n; j++){
if(a[i]+b[j]>=q.top())break;
q.pop();
q.push(a[i]+b[j]);
}
}
print();
return 0;
}