Time limit: 1 second Memory limit: 256 MB After the mafia of Narhet was able to rebuild…
- User
Time limit: 1 second Memory limit: 256 MB After the mafia of Narhet was able to rebuild its structure, it is time to reclaim the property that was unjustly given to some members and redistribute it among the members. Several years ago, the mafia bought an apartment on the top floor of all the buildings of the city's main market, which are all located on the same street, and housed each of its members in one of them in order to completely dominate the city market. The main market is located in the north-south direction and the value of each tower i i is equal to the number of buildings J It is located on the south side, the height is less than i i have and the height of all the buildings between i i and J j less than height J j is
For example, in the figure below, the value of each tower is written above it.
Mafia towers
Now your task is to calculate the value of each building in order to prepare for their distribution among the members.
input In the first line n n which ( 1 ≤ n ≤ 500
000 1≤n≤500 000) the number of buildings in the main market of the city comes and then in the next line n n is a number that indicates the height of the southernmost building to the northernmost building of this market. The height of each building is a natural number between 1 1 to 2 30 2 30 is
output In the output, you must print the value for each building, in other words, in the output in one line n Write n numbers that are the value of the southernmost building to the northernmost building in the market.
Example Sample entry 1 9 1 2 3 4 9 6 7 8 10 Plain text Sample output 1 0 1 1 1 1 0 1 1 2 write in java
- Assistant