#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector 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; vector> G(N); vector dp(N), deg(N, 0); set> se; rep(i,N) { dp[i] = X[i] + A[i]; se.insert({X[i] + A[i], i}); if(mp.count(X[i] + A[i])) { int to = mp[X[i] + A[i]]; G[to].push_back(i); deg[i]++; } if(mp.count(X[i] - A[i])) { int to = mp[X[i] - A[i]]; G[to].push_back(i); deg[i]++; } } while(!se.empty()) { queue q; auto it = se.end(); it--; q.push(it->second); se.erase(*it); while(!q.empty()) { int from = q.front(); q.pop(); for(int to : G[from]) { if(dp[to] < dp[from]) { dp[to] = dp[from]; se.erase({X[to] + A[to], to}); q.push(to); } } } } rep(i,N) cout << dp[i] - X[i] << '\n'; }