Codeforces 263B - Squares
Vasya has found a piece of paper with a coordinate system written on it. There are n distinct squares drawn in this coordinate system. Let’s number the squares with integers from 1 to n. It turned out that points with coordinates (0, 0) and (ai, ai) are the opposite corners of the i-th square.
Vasya wants to find such integer point (with integer coordinates) of the plane, that belongs to exactly k drawn squares. We’ll say that a point belongs to a square, if the point is located either inside the square, or on its boundary.
Help Vasya find a point that would meet the described limits.
Input:
The first line contains two space-separated integers n, k (1 ≤ n, k ≤ 50). The second line contains space-separated integers a1, a2, …, an (1 ≤ ai≤ 109).
Output:
In a single line print two space-separated integers x and y (0 ≤ x, y ≤ 109) — the coordinates of the point that belongs to exactly k squares. If there are multiple answers, you are allowed to print any of them.
If there is no answer, print “-1” (without the quotes).
範例:
input:
1 | 4 3 |
output:
1 | 2 1 |
input:
1 | 3 1 |
output:
1 | 4 0 |
input:
1 | 4 50 |
output:
1 | -1 |
題意:
在平面上有N個正方形,左下點都對齊(0, 0),請你找一個點,這個點剛好在K個正方形內,邊長保證都不會重複。
思路:
因為左下角都對齊了,而且是正方型又不會重複,所以只要從大的開始往小的找K個,假設他的邊長為L,則(L, 0)就是答案。