//g++ 2.cpp -std=c++14 -O2 -I . #include using namespace std; #include using namespace atcoder; using ll = long long; using ld = long double; using vi = vector; using vvi = vector; using vll = vector; using vvll = vector; using vld = vector; using vvld = vector; using vst = vector; using vvst = vector; #define fi first #define se second #define pb push_back #define eb emplace_back #define pq_big(T) priority_queue,less> #define pq_small(T) priority_queue,greater> #define all(a) a.begin(),a.end() #define rep(i,start,end) for(ll i=start;i<(ll)(end);i++) #define per(i,start,end) for(ll i=start;i>=(ll)(end);i--) #define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end()) using P = pair; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin>>n; vi x(n),a(n); rep(i,0,n)cin>>x[i]; rep(i,0,n)cin>>a[i]; map m; rep(i,0,n){ m[x[i]]=i+1; } vi opt(n); rep(i,0,n){ opt[i]=x[i]+a[i]; } pq_big(P) que; rep(i,0,n){ que.push({x[i]+a[i],i}); } while(!que.empty()){ auto [sm,id]=que.top(); que.pop(); int l=x[id]-a[id],r=x[id]+a[id]; if(m[l]!=0){ int nxt=m[l]-1; opt[id]=max(opt[id],opt[nxt]); } if(m[r]!=0){ int nxt=m[r]-1; opt[id]=max(opt[id],opt[nxt]); } } rep(i,0,n){ cout<