#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
int n; cin >> n;
vector<array<int, 2>> a(n + 2);
vector<int> b(n + 1), pre(n + 2), suf(n + 2), ans(n + 2);
for(int i = 1; i <= n + 1; i++){
cin >> a[i][0];
a[i][1] = i;
}
for(int i = 1; i <= n; i++) cin >> b[i];
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for(int i = 1; i <= n; i++) pre[i] = max(pre[i - 1], a[i][0] - b[i]);
for(int i = n; i >= 1; i--) suf[i] = max(suf[i + 1], a[i + 1][0] - b[i]);
for(int i = 1; i <= n + 1; i++) ans[a[i][1]] = max(pre[i - 1], suf[i]);
for(int i = 1; i <= n + 1; i++) cout << ans[i] << " ";
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |