#include #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i> n; vector a(n), x(n); rep(i, n) cin >> x[i]; rep(i, n) cin >> a[i]; vector dist(n, -1); vector> v; map mp; set s; rep(i, n) { v.push_back({a[i] + x[i], i}); mp[x[i]] = i; s.insert(x[i]); } sort(be(v)); reverse(be(v)); for(auto [e, i] : v) { chmax(dist[i], e); if(s.count(x[i] - a[i])) chmax(dist[i], dist[mp[x[i] - a[i]]]); if(s.count(x[i] + a[i])) chmax(dist[i], dist[mp[x[i] + a[i]]]); } rep(i, n) { cout << dist[i] - x[i] << endl; } return 0; }