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.
The first line contains two space-separated integers n, k (1 ≤ n, k ≤ 50). The second line contains space-separated integersa1, a2, ..., an (1 ≤ ai ≤ 109).
It is guaranteed that all given squares are distinct.
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 ksquares. If there are multiple answers, you are allowed to print any of them.
If there is no answer, print "-1" (without the quotes).
4 3
5 1 3 4
2 1
3 1
2 4 1
4 0
4 50
5 1 10 2
-1
对ai排序后从大到小数 即可
附代码:
1 #include<stdio.h> 2 #include<stdlib.h> 3 4 int cmp(const void *a,const void *b) 5 { 6 return *(int *)b-*(int *)a; 7 } 8 9 int arr[50]={0}; 10 11 int main(void) 12 { 13 int n, k, number, status=0; 14 int i; 15 scanf("%d %d", &n, &k); 16 for( i=0; i<n; i++) 17 scanf("%d", &arr[i]); 18 19 qsort( arr, n, sizeof(int), cmp); 20 for( i=1; i<=k; i++) 21 { 22 if( i>n) 23 { 24 i=n; 25 status=1; 26 break; 27 } 28 } 29 i--; 30 if( status) 31 printf("-1\n"); 32 else 33 printf("%d 0\n", arr[i-1]); 34 35 return 0; 36 }