#C9475. Find Kth Largest Element

    ID: 53572 Type: Default 1000ms 256MiB

Find Kth Largest Element

Find Kth Largest Element

Given an unsorted array of integers, find the \(k\)-th largest element in the array. For example, if the array is \([3, 2, 1, 5, 6, 4]\) and \(k=2\), the answer is 5.

Note: You may assume that \(k\) is always valid, 1 \(\leq k \leq n\), where \(n\) is the size of the array.

You are required to read input from standard input (stdin) and output your answer to standard output (stdout).

inputFormat

The first line of input contains two integers \(n\) and \(k\) where \(n\) is the number of elements in the array and \(k\) specifies which largest element to find. The second line contains \(n\) space separated integers representing the array elements.

outputFormat

Output a single integer, which is the \(k\)-th largest element of the array.

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

</p>