408548: GYM103185 E Excellent Views

Memory Limit:1024 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Excellent Viewstime limit per test0.3 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Shiny City is a beautiful city, famous for three things: the fact that it only has one street, the fact that all buildings have different heights, and the breathtaking views from the top of said buildings.

Since the pandemic began, the amount of tourists that visit Shiny City has gone down significantly. You are determined to write an amazing blog to attract more tourists and impede financial doom to your lovely, but terribly inefficient city. Unfortunately, there is still some information missing from the blog.

In Shiny City there are $$$N$$$ buildings, and the $$$i$$$-th building is identified by its position $$$i$$$. Going from building $$$i$$$ to building $$$j$$$ takes $$$|i - j|$$$ minutes. Each building has a different height $$$H_i$$$, and the taller the building, the better the view from its top.

If you are at a certain building, it might be worth going to a different building that has a better view. Because of transportation costs, it's never worth it to go to a building if there is a taller one that you can reach without using more time.

Formally, we can say that going from building $$$i$$$ to another building $$$j$$$ is worth it if there is no $$$k$$$ such that $$$|i - k| \leq |i - j|$$$ and $$$H_j < H_k$$$. Note that $$$k$$$ may be equal to $$$i$$$.

You want to write on your blog, for each building, how many other buildings are worth going to from it. Please gather this information, otherwise Shiny City will be forever doomed.

Input

The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 10^5$$$), the number of buildings in Shiny City. The second line contains $$$N$$$ different integers $$${H_1}, {H_2}, ldots, {H_N}$$$ ($$$1 \leq H_i \leq 10^9$$$ for $$${i}={1}, {2}, \ldots, {N}$$$), where $$$H_i$$$ is the height of building $$$i$$$.

Output

Output a single line with $$$N$$$ integers, such that the $$$i$$$-th of them represents the number of buildings worth going to from building $$$i$$$.

ExampleInput
10
23 20 7 30 43 70 5 42 67 10
Output
3 4 3 2 1 0 1 2 1 2

加入题单

算法标签: