#C1078. Bench Position Problem

    ID: 40022 Type: Default 1000ms 256MiB

Bench Position Problem

Bench Position Problem

You are given a park with n fountains. Each fountain has a specified radius. Your task is to determine a point (x, y) for placing a bench such that the bench is not wet by exactly k fountains.

To achieve this, sort the given radii in non-decreasing order. If k is not equal to n, the bench should be placed at the point with x-coordinate equal to the (n-k)th smallest radius (i.e. $$ x = \text{sorted_radii}[n-k] $$) and y-coordinate equal to 0. If k = n, then no such bench position exists, and you should output -1.

inputFormat

The input is provided via standard input (stdin) in the following format:

n k
r1 r2 r3 ... rn

where:

  • n is the number of fountains.
  • k is the number of fountains which should not wet the bench.
  • r1, r2, ... , rn are the radii of the fountains.

Note: It is guaranteed that 1 ≤ n ≤ 105 and 0 ≤ k ≤ n.

outputFormat

Output the bench's coordinates in the format x y if a valid position exists. Otherwise, output -1 (without quotes).

## sample
4 2
5 1 3 6
5 0