# [洛谷](P1631)序列合并 ---- 优先级队列+思维

AC代码：

#include<bits/stdc++.h>
#define rep(i,s,t) for(int i = (int)(s); i <= (int)(t); i++)
#define rev(i,t,s) for(int i = (int)(t); i >= (int)(s); i--)
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int maxn = 1e5+5;
const int maxm = 2e5+5;
int a[maxn];
int b[maxn];
int ans[maxn];
priority_queue<int> q;
//priority_queue<int, vector<int>, greater<int> > q1;
{
char x;
while((x = getchar())<'0' || x>'9');
int u = x-'0';
while((x = getchar())>='0' && x<='9') u = (u<<3)+(u<<1)+x-'0';
return u;
}
int main()
{
#ifdef LOCAL_FILE
freopen("in.txt","r",stdin);
#endif // LOCAL_FILE
//    ios_base::sync_with_stdio(0);
//    cin.tie(0),cout.tie(0);
int n;
sort(a,a+n);
sort(b,b+n);
rep(i,0,n-1) q.push(a[0]+b[i]);
rep(i,1,n-1)
{
rep(j,0,n-1)
{
int e = a[i]+b[j];
if(e<q.top())
{
q.pop();
q.push(e);
}
else break;
}
}
//cout<<q.size()<<endl;
rep(i,0,n-1)
{
int e = q.top();
ans[i] = e;
q.pop();
}
rev(i,n-1,0) printf("%d ",ans[i]);
return 0;

}
/*
4
1 2 4 4
1 1 1 5

*/