-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path977C.cpp
More file actions
68 lines (59 loc) · 967 Bytes
/
Copy path977C.cpp
File metadata and controls
68 lines (59 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
void inp()
{
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
}
ll min(ll a,ll b)
{
if(a<b)
return a;
else
return b;
}
ll max(ll a,ll b)
{
if(a>b)
return a;
else
return b;
}
int main() {
fio;
ll n,k;
cin>>n>>k;
vector<int> v(n);
for(int i=0;i<n;i++)
{
cin>>v[i];
}
sort(v.begin(),v.end());
if(k==0)
{
if(v[0]-1<=0)
{
cout<<"-1"<<endl;
}
else{
cout<<v[0]-1<<endl;
}
}
else if(v[k]==v[k-1])
{
cout<<"-1"<<endl;
}
else
{
cout<<v[k-1]<<endl;
}
return 0;
}