Squares

CodeForces - 263B

Vasya has found a piece of paper with a coordinate system written on it. There are ndistinct 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 nk (1 ≤ n, k ≤ 50). The second line contains space-separated integers a1, 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 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).

Examples

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

sol:排序之后倒序往回找K个,找到n-K+1个正方形,一维坐标是它的边长,还有一维是0,这样一定是可以的
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=;
int n,K,a[N];
int main()
{
int i;
R(n); R(K);
for(i=;i<=n;i++) R(a[i]);
if(K>n) return *puts("-1");
sort(a+,a+n+);
W(a[n-K+]); Wl();
return ;
}
 

codeforces263B的更多相关文章

随机推荐

  1. 简述DDOS攻击的工作原理

    1.DDOS攻击:大量的肉鸡对服务器的不同端口发送巨型流量的UDP报文,无法通关关闭端口的方式来进行隔离,破坏力极强,严重会造成服务器当机. SYN/ACK Flood攻击:经典最有效的DDOS方法. ...

  2. CF434D Nanami's Power Plant 最小割

    传送门 因为连距离限制的边的细节调了贼久QAQ 这个题和HNOI2013 切糕性质相同,都是有距离限制的最小割问题 对于每一个函数,用一条链记录变量\(x\)在不同取值下这个函数的贡献.对于一个\(x ...

  3. Docker镜像构建

    一.简介 在构建容器化应用时,相当重要的步骤莫过于镜像制作,本文将介绍镜像制作方法以及镜像制作的建议.通常镜像的制作有两种方式: 使用现有的容器使用docker commit 生成镜像 使用Docke ...

  4. 20175234 数据库MySQL(课下作业)

    20175234 数据库MySQL(课下作业) 内容: 1.下载附件中的world.sql.zip, 参考http://www.cnblogs.com/rocedu/p/6371315.html#SE ...

  5. Java执行JavaScript脚本破解encodeInp()加密

    一:背景 在模拟登录某网站时遇到了用户名和密码被JS进行加密提交的问题,如图: 二:解决方法 1.我们首先需要获得该JS加密函数,一般如下: conwork.js var keyStr = " ...

  6. A2D JS框架 - loadScript实现

    其实这个功能比较小,本着自己造轮子的优良传统....就自己造一个好了 <head> <title></title> <script src="A2D ...

  7. ML.NET 示例:聚类之鸢尾花

    写在前面 准备近期将微软的machinelearning-samples翻译成中文,水平有限,如有错漏,请大家多多指正. 如果有朋友对此感兴趣,可以加入我:https://github.com/fei ...

  8. 谈谈自己体会到的HTML5

    # 谈谈自己体会到的HTML5 很多介绍HTML5的文章,都是从以下几个方面去介绍的:语义化.丰富的表单.本地存储.多媒体.地理位置等等.纸上得来终觉浅,现在有了一定的实践经验之后,本人对其有了更加深 ...

  9. H5 36-背景定位属性

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. Yii框架的增删改查总结分析

    一.查询数据 1.findAll(根据一个条件查询一个集合) $admin=Admin::model()->findAll($condition,$params); $admin=Admin:: ...