#include using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template using V = vector; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; V X(N), A(N); rep(i, N) cin >> X[i]; rep(i, N) cin >> A[i]; map mp; rep(i, N) mp[X[i]] = i; V> G(N); rep(i, N) { if (mp.count(X[i] + A[i])) { // i -> mp[X[i] + A[i]] に行ける G[mp[X[i] + A[i]]].push_back(i); } if (mp.count(X[i] - A[i])) { G[mp[X[i] - A[i]]].push_back(i); } } V ans(N); rep(i, N) ans[i] = X[i] + A[i]; V seen(N, 0); V ind(N); iota(ind.begin(), ind.end(), 0); sort(ind.begin(), ind.end(), [&](int i, int j) { return ans[i] < ans[j]; }); for (int i = N - 1; i >= 0; i--) { int cv = ind[i]; if (seen[cv]) continue; queue que; que.push(cv); while (!que.empty()) { int v = que.front(); que.pop(); if (seen[v]) continue; seen[v] = 1; for (auto nx : G[v]) { ans[nx] = max(ans[nx], ans[v]); if (seen[nx] == 0) { que.push(nx); } } } } rep(i, N) cout << ans[i] - X[i] << '\n'; return 0; }