#K8841. Top K Severe Incidents
Top K Severe Incidents
Top K Severe Incidents
You are given a total of n incidents with their corresponding severity levels represented as integers. Your task is to identify and output the top k incidents with the highest severity. The output must be in descending order.
Formally, given an integer \(n\) indicating the number of incidents, an array \(a = [a_1, a_2, \dots, a_n]\) where \(a_i\) denotes the severity level of the \(i\)th incident, and an integer \(k\), output the \(k\) highest values from the array in descending order. If \(k = 0\), produce no output.
inputFormat
The input is read from standard input (stdin) in the following format:
- The first line contains an integer (n), the number of incidents.
- The second line contains (n) space-separated integers representing the severity levels.
- The third line contains an integer (k), indicating how many of the top severity incidents to output.
outputFormat
Print the top (k) severity levels in descending order, separated by a space. If (k) is 0, output nothing.## sample
10
1 23 5 76 8 45 9 4 12 15
3
76 45 23