#K34237. Find the k-th Smallest Coin

    ID: 25265 Type: Default 1000ms 256MiB

Find the k-th Smallest Coin

Find the k-th Smallest Coin

You are given a collection of n coins with different values. Your task is to find the k-th smallest coin in the collection.

To solve the problem, sort the list of coin values in non-decreasing order and return the coin at position k (using 1-based indexing).

The solution should read input from stdin and output the result to stdout.

inputFormat

The input consists of two lines:

  • The first line contains two integers n and k, where n is the number of coins and k is the 1-based index of the coin to find after sorting.
  • The second line contains n space-separated integers representing the values of the coins.

outputFormat

Output a single integer representing the value of the k-th smallest coin.

## sample
5 3
100 200 50 300 150
150