#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 11;
const int inf = 1e18 + 7;
int pf[N], sf[N], b[N], ans[N];
pair < int, int > a[N];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int n;
cin >> n;
for(int i = 1; i <= n + 1; i++) a[i].second = i, cin >> a[i].first;
for(int i = 1; i <= n; i++) cin >> b[i];
sort(b + 1, b + 1 + n);
sort(a + 1, a + 2 + n);
for(int i = 1; i <= n; i++){
pf[i] = max(pf[i - 1], a[i].first - b[i]);
}
for(int i = n; i >= 1; i--){
sf[i] = max(sf[i + 1], a[i + 1].first - b[i]);
}
ans[a[n + 1].second] = pf[n];
for(int i = 1; i <= n; i++){
ans[a[i].second] = max(pf[i], sf[i]);
}
for(int i = 1; i <= n + 1; i++) cout << ans[i] << ' ';
}
// subete no mono no owari wa sugu ni yattekuru
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |