#K7156. Finding k-Dominators

    ID: 33558 Type: Default 1000ms 256MiB

Finding k-Dominators

Finding k-Dominators

Given an array of integers and an integer \( k \), an integer \( x \) from the array is called a k-dominator if the number of elements strictly greater than \( x \) is at most \( k \). Formally, if the sorted array (in non-decreasing order) is \( a_0, a_1, \dots, a_{n-1} \), then \( a_i \) is a k-dominator if:

\( n - i - 1 \le k \)

Your task is to output all the k-dominators in ascending order.

For example, given the array [3, 1, 4, 1, 5, 9, 2, 6, 5, 3] and \( k = 2 \), the sorted array is [1, 1, 2, 3, 3, 4, 5, 5, 6, 9] and the k-dominators are the last 3 elements: [5, 6, 9].

inputFormat

The first line contains two integers \( n \) and \( k \), where \( n \) is the number of elements in the array and \( k \) is the parameter that determines the k-dominator condition.

The second line contains \( n \) space-separated integers representing the array.

outputFormat

Output the k-dominators in ascending order, separated by a space.

## sample
10 2
3 1 4 1 5 9 2 6 5 3
5 6 9