#K92262. Kth Largest Unique Number

    ID: 38159 Type: Default 1000ms 256MiB

Kth Largest Unique Number

Kth Largest Unique Number

Given a list of n integers and a positive integer k, find the kth largest unique number in the list. If there are fewer than k unique numbers, output -1.

The problem requires you to read from standard input and output the result to standard output.

For example, if the input is:

10 3
5 2 4 6 8 2 3 6 5 7

the unique numbers sorted in descending order are \(8, 7, 6, 5, 4, 3, 2\), and the 3rd largest unique number is 6.

inputFormat

The first line of input contains two integers n and k separated by a space, where n is the number of elements in the list and k is the position of the unique number to retrieve.

The second line contains n integers separated by spaces.

outputFormat

Output a single integer: the kth largest unique number. If there are fewer than k unique numbers, output -1.

## sample
10 3
5 2 4 6 8 2 3 6 5 7
6