Xiao Ming bought a ribbon with $$$n$$$ segments. The $$$i$$$-th segment initially has color $$$c_i$$$. Xiao Ming prefers solid-colored ribbons, so he needs to paint every segment of this ribbon the same color.
For a painting operation $$$(l, r, c)$$$, it means that the interval $$$[l, r]$$$ of the ribbon can be painted with color $$$c$$$ at a cost of $$$w_c + (r - l + 1)$$$, where $$$w_c$$$ is the price of color $$$c$$$.
Now, for each color $$$c = 1, 2, ..., n$$$, please determine the minimum cost for Xiao Ming to paint the entire ribbon into color $$$c$$$.
The first line contains $$$n$$$.
The second line contains $$$n$$$ positive integers, representing $$$c_1, ..., c_n$$$.
The third line contains $$$n$$$ positive integers, representing $$$w_1, ..., w_n$$$.
$$$1 \leq n \leq 2 \times 10^5$$$, $$$1 \leq c_i, w_i \leq n$$$.
Output a single line containing $$$n$$$ numbers, representing the answers for colors $$$1, 2, ..., n$$$.
41 2 2 11 10 2 1
3 14 6 5
51 3 2 3 55 5 5 5 5
9 10 10 10 9