#include <algorithm>
#include <cstdio>
#include <queue>
#include <iostream>
#include <vector>
#include <functional>
#include <stdlib.h>
#include <stack>
using namespace std;
int n, a [100010], b [100010];
priority_queue <int> que;
stack <int> Q;
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 ++) {
for (int j = 1; j <= n; j ++) {
// cout << 'x';
if (que.size () < n)
que.push (a [i] + b [j]);
else {
if (a [i] + b [j] >= que.top ())
break;
else {
que.pop ();
que.push (a [i] + b [j]);
}
}
}
cout << endl;
}
while (!que.empty ()) {
Q.push (que.top ());
que.pop ();
}
while (!Q.empty ()) {
cout << Q.top () << ' ';
Q.pop ();
}
return 0;
}
1245 最小的N个和
最新推荐文章于 2020-04-16 16:26:39 发布