|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||21||13||11||61.111%|
Given is a sequence of N integers a1, a2, ..., an. For any element ak (k = 1, 2, ..., n) we find the first larger than ak element, which is placed to the right of ak (if such exists). Denote it by ak1. Then do the same with ak1 and denote the found element by ak2, and so on until we run out of the given sequence. Thus formed subsequence ak1, ak2, ..., we call chain beginning at index k.
Write program chain that outputs for any index k the length of the corresponding chain that begins at index k.
On the first line of the standard input, the value of N is written. On the second line, the elements of the given sequence are written, separated by spaces.
On a line in the standard output, your program has to write the sequence of chain’s lengths, corresponding to the element of the input data. Each two consecutive numbers in the output must be separated by a single space.
11 3 2 4 2 11 2 7 5 8 10 6
2 2 1 1 0 3 2 2 1 0 0