附网址:http://acm.uestc.edu.cn/#/problem/show/1329
这道题就是数据结构了 还是比较明显的优先队列吧
虽然我想了很久,最后还是看了题解
思路:压入(a[i]+b[1]) 最后一个双重循环拉出队列 压入(a[i]+b[k] k为枚举量) 最后队列里前N个就是答案
//by liucxy
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int N,n,a[100005],b[100005];
typedef pair<int,int> pii;
priority_queue<pii,vector<pii>,greater<pii> > q;
int main()
{
scanf("%d",&N);
for (int i=1;i<=N;i++) scanf("%d",&a[i]);
for (int i=1;i<=N;i++) scanf("%d",&b[i]);
sort(a+1,a+1+N);
sort(b+1,b+1+N);
for (int i=1;i<=N;i++)
q.push(make_pair(a[i]+b[1],1));
for (int i=1;i<=N;i++)
{
pii hehe=q.top();q.pop();
int k=hehe.second;
int haha=hehe.first;
printf("%d\n",haha);
q.push(make_pair(haha-b[k]+b[k+1],k+1));
}
return 0;
}