問題一覧 > 通常問題

No.1090 Social Distance

レベル : / AI推定難易度 : 147 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 165
作問者 : null / テスター : butsurizuki
お気に入りにしたユーザー ProblemId : 4571 / 自分の提出
問題文最終更新日: 2026-10-15 20:16:26
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

Problem Statement

$N$ people are standing on a number line, and person $1$ is at position $0$.
The distance from person $i - 1(2 \le i \le N)$ to person $i$ is $a_i$ in the positive direction.
Due to the spread of a new virus, the distance between people must now be at least $D$ as social distancing.
Therefore, in order starting from person $2$, person $i$, if their distance from person $i-1$ is less than $D$, moves in the positive direction until the distance becomes $D$.
If this move reverses their position relative to person $i+1$, it is treated as a negative distance. In other words, to satisfy the condition, in the end person $i+1$ is always at a larger coordinate than person $i$.
Output the coordinates of all $N$ people after social distancing.

Input

$N\ D$
$a_2\ a_3\ \dots a_N$

$2 \le N \le 10^5$
$1 \le D, a_i \le 1000(=10^3)$

Output

Print the coordinates of the $N$ people on one line, separated by spaces. Do not put a trailing space. End the output with a newline.

Sample

Sample 1
Input
5 2
1 2 3 1000
Output
0 2 4 6 1006

They were at $0, 1, 3, 6, 1006$ respectively, but the $2, 3$-th people shifted by $+1$.

Sample 2
Input
10 90
1 2 3 4 5 6 7 8 9
Output
0 90 180 270 360 450 540 630 720 810

Source

YSF Beginner Contest: C - Social Distance
writer: null
tester: butsuri_0523
Ported in accordance with HackerRank's terms. Some parts have been modified due to circumstances such as those of the site.

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