#C10528. Top K Employee Indices

    ID: 39743 Type: Default 1000ms 256MiB

Top K Employee Indices

Top K Employee Indices

You are given an array of performance scores of employees. Your task is to output the indices of the top k employees based on their scores. The employees are ranked based on their scores in descending order. In the case of a tie, the employee with the smaller index (i.e., appearing earlier in the array) should be ranked higher.

The problem can be formalized as follows: Given an array \(S\) of performance scores and an integer \(k\), find indices \(i_1, i_2, \ldots, i_k\) such that for all valid \(j\),

[ S[i_j] \ge S[i_{j+1}], \quad \text{and if } S[i_j] = S[i_{j+1}], \text{ then } i_j < i_{j+1]. ]

Note that the indices are 0-indexed. The input will be provided via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The first line of input contains two integers \(n\) and \(k\) (1 \(\le\) \(k\) \(\le\) \(n\)) representing the number of employees and the number of top employees to select, respectively.

The second line contains \(n\) space-separated integers representing the performance scores of the employees.

outputFormat

Print a single line with \(k\) space-separated integers representing the indices of the top \(k\) employees as per the criteria described above.

## sample
5 3
90 85 90 70 95
4 0 2