#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
#define ii pair <int, int>
#define fi first
#define se second
const int N = 2e5 + 10;
class CMP {
public:
bool operator () (const int &x, const int &y) const {
return x > y;
}
};
int n, x[N], ans[N];
ii a[N];
multiset <int, CMP> ms;
int main() {
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n + 1; ++i) {
cin >> a[i].fi;
a[i].se = i;
}
sort(a + 1, a + n + 2);
for (int i = 1; i <= n; ++i) cin >> x[i];
sort(x + 1, x + n + 1);
for (int i = 1; i <= n; ++i) {
ms.insert(max(0, a[i].fi - x[i]));
}
for (int i = n + 1; i >= 1; --i) {
ans[a[i].se] = *ms.begin();
if (i > 1) {
ms.erase(max(0, a[i - 1].fi - x[i - 1]));
ms.insert(max(0, a[i].fi - x[i - 1]));
}
}
for (int i = 1; i <= n + 1; ++i) {
cout << ans[i] << " ";
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |