問題一覧 > 通常問題

No.1950 One-Way Catch Ball

レベル : / AI推定難易度 : 1350 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 97
作問者 : H20 / テスター : null 蜜蜂
お気に入りにしたユーザー ProblemId : 7891 / 自分の提出
問題文最終更新日: 2022-05-21 00:42:17
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 344 (順位表) の他の問題:

Problem Statement

$N$ people stand in a row on a straight line.

The $i$-th person from the left is at position $X_i$ and can throw a ball, without a bounce, a distance of exactly $A_i$ to the left or right.

Each of the $N$ people throws a ball without moving from their fixed position and measures the distance the ball travels until it lands on the ground.

A distance traveled to the right is positive, and a distance traveled to the left is negative. They want to throw the ball as far as possible in the positive direction.

Having twisted the rules, the $N$ people decided to extend the distance as follows: if there is a person at the position where the ball lands, that person catches it and throws it again.

Under the twisted rules, find the maximum distance each of the $N$ people can throw, expressed as the maximum distance in the positive direction from the position of the $i$-th person.

Input

$N$
$X_1$ $X_2$ $\ldots$ $X_N$
$A_1$ $A_2$ $\ldots$ $A_N$

Constraints

  • $ 1 \le N \le 2\times10^{5}$
  • $ 0 \le X_i \le 10^{9}$
  • $X_1 \lt X_2 \lt \ldots \lt X_N$
  • $ 1 \le A_i \le 10^{9}$
  • All input values are integers.

Output

Print $N$ lines.

On the $i$-th line, print the maximum distance for the $i$-th person from the left.

Print a newline at the end.

Sample

Sample 1
Input
4
0 2 3 4
2 9 5 2
Output
11
9
5
7

The $1$-st and $4$-th people were able to extend their distances by having the $2$-nd person, who is at the landing position, throw the ball.

Sample 2
Input
7
3 14 15 92 653 5897 9323
10 10 10 10 10 10 10
Output
10
10
10
10
10
10
10

There was nobody at any of the landing positions.

Sample 3
Input
10
0 5 7 10 15 20 25 30 35 40 
5 5 8 20 10 20 25 10 40 10
Output
50
45
43
40
35
30
25
20
40
10

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。