#K34987. K-th Largest Element Finder

    ID: 25431 Type: Default 1000ms 256MiB

K-th Largest Element Finder

K-th Largest Element Finder

Given an array of integers and an integer ( k ), determine the ( k )-th largest element in the array. The ( k )-th largest element is the element that would appear in the ( k )-th position if the array were sorted in descending order. This evaluation requires handling unsorted data efficiently and is a common task in algorithmic problem solving. Efficient solutions are expected to work well even on large datasets.

inputFormat

The input is read from standard input (stdin). ( n ) is given on the first line representing the number of elements in the array. The second line contains ( n ) space-separated integers. The third line contains a single integer ( k ), indicating which largest element to find.

outputFormat

Print a single integer to standard output (stdout), which is the ( k )-th largest element in the array.## sample

6
3 2 1 5 6 4
2
5