#include <bits/stdc++.h>
using namespace std;
#define int long long
int jaw[300005], arr[300005], ARR[300005], n, m, pref[300005], suff[300005];
vector<pair<int, int>> v;
vector<int> x;
signed main() {
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin >> n;
for(int i = 1; i <= n + 1; i++) {
cin >> arr[i];
v.push_back({arr[i], i});
}
sort(v.begin(), v.end());
for(int i = 1; i <= n; i++) {
cin >> ARR[i];
x.push_back(ARR[i]);
}
sort(x.begin(), x.end());
for(int i = 0; i < x.size(); i++) {
pref[i + 1] = max(pref[i], v[i].first - x[i]);
}
for(int i = 0; i < x.size(); i++) {
suff[x.size() - i] = max(suff[x.size() - i + 1], v[v.size() - 1 - i].first - x[x.size() - 1 - i]);
}
for(int i = 0; i < v.size(); i++) {
int jaw = pref[i];
int brp = v.size() - 1 - i;
jaw = max(jaw, suff[x.size() + 1 - brp]);
cout << jaw << " ";
//cout << max(pref[i], suff[i + 1]) << " ";
}
cout << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |