codeforces 161 Div2 B
2013-01-17 23:01
2021 查看
B. Squares
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 integersa1, a2, ..., an (1 ≤ ai ≤ 109).
It is guaranteed that all given squares are distinct.
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 ksquares. If there are multiple answers, you are allowed to print any of them.
If there is no answer, print "-1" (without the quotes).
Sample test(s)
input
output
input
output
input
output
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 integersa1, a2, ..., an (1 ≤ ai ≤ 109).
It is guaranteed that all given squares are distinct.
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 ksquares. If there are multiple answers, you are allowed to print any of them.
If there is no answer, print "-1" (without the quotes).
Sample test(s)
input
4 3 5 1 3 4
output
2 1
input
3 1 2 4 1
output
4 0
input
4 50 5 1 10 2
output
-1 对ai排序后从大到小数 即可 附代码:
#include<stdio.h> #include<stdlib.h> int cmp(const void *a,const void *b) { return *(int *)b-*(int *)a; } int arr[50]={0}; int main(void) { int n, k, number, status=0; int i; scanf("%d %d", &n, &k); for( i=0; i<n; i++) scanf("%d", &arr[i]); qsort( arr, n, sizeof(int), cmp); for( i=1; i<=k; i++) { if( i>n) { i=n; status=1; break; } } i--; if( status) printf("-1\n"); else printf("%d 0\n", arr[i-1]); return 0; }
相关文章推荐
- codeforces 161 Div2 A
- codeforces基础题——#161(div2) E
- 【codeforces】Codeforces Round #283 (Div. 2) 【题解】
- 【Codeforces】Codeforces Round #373 (Div. 2)
- CodeForces 498A Round #284 div1A(div2C) Crazy Town
- Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学
- codeforces-div1-284-D
- CodeForces 601A The Two Routes(dijkstra最短路)——Codeforces Beta Round #333 (Div.1 Div. 2)
- [Codeforces]Educational Codeforces Round 37 (Rated for Div. 2)
- Codeforces Div. 2 #257-C. Jzzhu and Chocolate
- Codeforces 285 div2 b
- 【codeforces】Codeforces Round #277 (Div. 2) 解读
- Codeforces 410 div 2 【解题报告】
- Codeforces #211 (Div. 2) A. Soroban
- codeforces 170 div2 C
- CodeForces-428-div2-c
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort(暴力)
- Codeforces Beta Round #29 (Div. 2, Codeforces format) C. Mail Stamps 拓扑排序
- codeforces 428(div2) A-D
- 【Codeforces】Round #376 (Div. 2)