You have $$$n$$$ boxes. You are given a binary string $$$boxes$$$ of length $$$n$$$, where $$$boxes_i$$$ is '$$$0$$$' if the $$$i_{th}$$$ box is empty, and '$$$1$$$' if it contains one ball.
In one operation, you can move one ball from a box to an adjacent box. $$$Box_i$$$ is adjacent to $$$box_j$$$ if $$$abs(i - j) = 1$$$.
Note that after doing so, there may be more than one ball in some boxes.
Print an array $$$answer$$$ of size $$$n$$$, where $$$answer_i$$$ is the minimum number of operations needed to move all the balls to the $$$i_{th}$$$ box.
Each $$$answer_i$$$ is calculated considering the initial state of the boxes.
The first line contains a single integer $$$n$$$ $$$(1 \leq n \leq 2×10^5)$$$ — the number of boxes.
The second line contains a single string $$$boxes$$$.
Print an array $$$answer$$$ of size $$$n$$$, where $$$answer_i$$$ is the minimum number of operations needed to move all the balls to the $$$i_{th}$$$ box.
3110
1 1 3
6001011
11 8 5 4 3 4
| Название |
|---|


