#include<stdio.h>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
struct node{
int sum,bi;
friend bool operator < (node aa,node bb){
return aa.sum>bb.sum;
}
};
priority_queue<node>q;
int n,a[100010],b[100010],bi=1;
int main(){
freopen("1245.in","r",stdin);
freopen("1245.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
sort(a+1,a+n+1);
for(int i=1;i<=n;i++) scanf("%d",&b[i]);
sort(b+1,b+n+1);
for(int i=1;i<=n;i++){
node x;
x.sum=a[i]+b[1];
x.bi=1;
q.push(x);
}
for(int i=1;i<=n;i++){
node x=q.top();
q.pop();
printf("%d ",x.sum);
if(x.bi<=n){
node y;
y.sum=x.sum-b[x.bi]+b[x.bi+1];//x.sum-b[x.bi]=a[]
y.bi=x.bi+1;
q.push(y);
}
}
return 0;
}
本题没有完全搞懂。。。