#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
using namespace std;
int b[200010];
int l[200010];
int r[200010];
pair<int,int> a[200010];
int c[200010];
void solve () {
int n; cin >> n;
for (int i = 1; i <= n + 1; i++) {cin >> a[i].F; a[i].S = i;}
for (int i = 1; i <= n; i++) cin >> b[i];
sort(a + 1, a + 1 + n + 1);
sort(b + 1, b + 1 + n);
for (int i = 1; i <= n; i++) l[i] = max(l[i-1], a[i].F - b[i]);
for (int i = n; i >= 1; i--) r[i] = max(r[i+1], a[i+1].F - b[i]);
for (int i = 0; i <= n; i++) c[a[i+1].S] = max(l[i], r[i+1]);
for (int i = 1; i <= n + 1; i++) cout << c[i] << ' ';
}
signed main() {IOS solve(); 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... |