#STK0000077. Tháp thu tín hiệu (Tower)
Tháp thu tín hiệu (Tower)
Tower
Source: Baekjoon Online Judge
Version: Phuoc Hung OJ Extended
Problem Statement
There are towers of distinct heights arranged from left to right and numbered through . Every tower emits a horizontal laser to the left. The laser from tower is received by the first tower to its left whose height is greater than ; shorter towers do not block it. If no such tower exists, the answer is . Determine the receiving tower for every transmitter.
Input
The first line contains . The second line contains the tower heights from left to right. All heights are distinct.
Output
Print integers. The -th integer is the index of the tower that receives the laser from tower , or if no tower receives it.
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
6 9 5 7 4
Output
0 0 2 2 4
Explanation
The tower heights are .
- Tower has no tower to its left, so its answer is .
- Tower has height . Its laser passes tower of height , and there is no taller tower farther left, so its answer is .
- Tower has height and immediately meets tower of height , so its answer is .
- Tower has height . Its laser passes tower of height and then reaches tower of height , so its answer is .
- Tower has height and immediately reaches tower of height , so its answer is .
Therefore the output is 0 0 2 2 4.