#K13906. Maximize Books in Good Condition
Maximize Books in Good Condition
Maximize Books in Good Condition
You are given n books, each with a wear tolerance value. During maintenance, each book undergoes a wear factor c. In order to maximize the number of books remaining in good condition, the books should be arranged in such a way that those with higher wear tolerance are processed first. Formally, given an array \(w = [w_1, w_2, \ldots, w_n]\) of wear tolerance values and an integer \(c\), you are to output a permutation of the indices \(1,2,\ldots,n\) such that if the books are processed in that order, the maximum number of books remain in good condition. In this problem, the parameter \(c\) is provided but does not affect the optimal ordering; the answer is simply to sort the books in descending order of their wear tolerance.
Note: If two books have the same wear tolerance, they should maintain the relative order as in the original input (i.e. stable sorting by index). The expected order is the sorted order of the indices (1-indexed) based on the corresponding wear tolerance values.
The formula for sorting can be expressed as follows: \[ \text{Sort } (w_i, i) \text{ such that if } w_i > w_j \text{ then } i \text{ comes before } j. \]
inputFormat
The input is given from stdin in the following format:
- The first line contains an integer n representing the number of books.
- The second line contains n space-separated integers, which represent the wear tolerance values \(w_1, w_2, \ldots, w_n\) of the books.
- The third line contains an integer c representing the wear factor applied during maintenance (this value does not affect the ordering).
outputFormat
Output to stdout a single line containing n space-separated integers – the order in which the books should be maintained. These integers are 1-indexed and represent the positions of the books in the initial input order.
## sample5
10 2 3 7 5
3
1 4 5 3 2