#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
struct node
{
int num,p,total;
friend bool operator<(node a,node b)
{
return a.total>b.total;
}
};
int a[100009];
int b[100009];
priority_queue<node> heap;
int main()
{
int m;
scanf("%d",&m);
for(int i=1;i<=m;i++)
scanf("%d",&a[i]);
for(int i=1;i<=m;i++)
scanf("%d",&b[i]);
sort(a+1,a+m+1);
sort(b+1,b+m+1);
for(int i=1;i<=m;i++)
{
node x;
x.total=a[i]+b[1];
x.p=1;
x.num=a[i];
heap.push(x);
}
for(int i=1;i<=m;i++)
{
cout<<heap.top().total<<" ";
node x=heap.top();
heap.pop();
x.total-=b[x.p];
x.p++;
x.total+=b[x.p];
heap.push(x);
}
return 0;
}
序列合并
最新推荐文章于 2024-04-25 08:00:00 发布