#C823. Find the K-th Smallest Element

    ID: 52189 Type: Default 1000ms 256MiB

Find the K-th Smallest Element

Find the K-th Smallest Element

You are given an array of n integers and an integer k. Your task is to determine the k-th smallest element in the array. Formally, if the array is sorted in non-decreasing order, you should output the element at position k (1-indexed). Specifically, if the sorted array is \(a_1, a_2, \ldots, a_n\), you need to output \(a_k\). This problem tests your ability to sort data and index the correct element.

Note: It is guaranteed that 1 \(\leq\) k \(\leq\) n.

inputFormat

The first line of input contains two positive integers n and k separated by a space, where n is the number of elements in the array, and k is the position of the smallest element to find. The second line contains n space-separated integers representing the elements of the array.

Input Format: n k arr[0] arr[1] ... arr[n-1]

outputFormat

Output a single integer denoting the k-th smallest element of the array.

## sample
6 3
7 10 4 3 20 15
7