#K41292. Sort Books by Popularity
Sort Books by Popularity
Sort Books by Popularity
You are given n books with their corresponding popularity scores. The books are numbered from 1 to n in the order of their appearance.
Your task is to sort the books in descending order according to their popularity scores. In case of a tie where two books have the same popularity score, maintain their original order (i.e. the one that appears sooner in the input should come first).
Formally, let the score of the book i be denoted as \(s_i\). You need to output a permutation \(p_1, p_2, \dots, p_n\) of \(\{1, 2, \dots, n\}\) such that for any two positions \(i\) and \(j\) with \(i
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains a single integer \(n\) indicating the number of books.
- The second line contains \(n\) space-separated integers representing the popularity scores of the books.
outputFormat
Output to standard output (stdout) a single line containing \(n\) space-separated integers representing the book numbers in sorted order by descending popularity (maintaining initial order for equal scores).
## sample4
10 50 30 20
2 3 4 1