#include #include #include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using modint = atcoder::static_modint<998244353>; int main(){ int N; cin >> N; vector X(N); rep(i,N) cin >> X[i]; vector A(N); rep(i,N) cin >> A[i]; auto search_node = [&](int x) -> int { int p = lower_bound(X.begin(), X.end(), x) - X.begin(); if(p == N) return -1; if(X[p] == x) return p; return -1; }; vector> edges(N); rep(i,N){ int to = search_node(X[i] - A[i]); if(to >= 0) edges[to].push_back(i); } rep(i,N){ int to = search_node(X[i] + A[i]); if(to >= 0) edges[to].push_back(i); } vector> Q(N); rep(i,N) Q.push_back(make_pair(X[i]+A[i], i)); sort(Q.begin(), Q.end()); reverse(Q.begin(), Q.end()); vector ans(N, -1); vector bfs; int bfsi = 0; for(auto [sd,s] : Q) if(ans[s] == -1){ ans[s] = sd; bfs.push_back(s); while(bfsi < (int)bfs.size()){ int p = bfs[bfsi++]; for(int e : edges[p]) if(ans[e] == -1){ bfs.push_back(e); ans[e] = ans[p]; } } } rep(i,N) ans[i] -= X[i]; rep(i,N) cout << ans[i] << '\n'; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;