#P7787. [COCI 2016/2017 #6] Turnir
[COCI 2016/2017 #6] Turnir
Description
You are given a sequence of positive integers. In each round, these numbers are compared in the given order: the larger number stays, and the smaller number is eliminated, until only one number remains.
Now you are given the initial order of these numbers. Please find, for each number, the maximum round it can survive to.
Input Format
The first line contains an integer .
The second line contains integers , representing the numbers in the sequence.
Output Format
Output one line with integers, where the -th integer represents the round that the -th number can survive to.
2
1 4 3 2
2 0 1 1
4
5 3 2 6 4 8 7 1 2 4 3 3 6 4 8 1
1 2 2 1 1 0 1 3 2 1 2 2 1 1 0 3
1
1 1
0 0
Hint
[Sample Explanation #2]

[Constraints]
For of the testdata, , .
[Note]
The scoring of this problem follows the original COCI settings, with a full score of .
This problem is translated from COCI2016_2017 CONTEST #6 T3 TURNIR.
Translated by ChatGPT 5
京公网安备 11011102002149号