#STK0000081. Các tòa nhà (Buildings)
Các tòa nhà (Buildings)
Buildings
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are buildings numbered through , where building has height . All heights are distinct. For every , count the indices such that no building strictly between and is taller than building .
Input
The first line contains . The second line contains integers .
Output
Print integers; the -th integer is the number of buildings satisfying the condition for building .
Subtasks
- Subtask 1 (30 points): ; all other conditions are unchanged.
- Subtask 2 (70 points): , , các đôi một khác nhau.
Examples
Input
5
2 1 4 3 5
Output
3 2 2 1 0
Explanation
The heights are .
- For , the valid indices are . Index is invalid because building of height lies between them and is taller than building of height . Hence .
- For , and are valid, while is blocked by the taller building . Thus .
- For , both and satisfy the condition, so .
- For , only is available and valid, so .
- For , there is no building to the right, so .
Therefore the program prints 3 2 2 1 0.