考虑到了可能存在重复元素情况
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
int n, x, y, ans = -1;
cin >> n >> x >> y;
vector<int> arr(n, 0);
for(int i = 0; i < n; ++i) {
cin >> arr[i];
}
std::sort(arr.begin(), arr.end());
// 只有 x*2 <= n <= y*2 才有可能存在解
if(x*2 <= n && y*2 >= n) {
// 如果取x导致n-x大于y,则x向前走
while(n - x > y) ++x;
// 如果存在重复元素,则x向前走
while(arr[x] == arr[x-1]) ++x;
// 如果x没有超过区间范围,则arr[x-1]就是m
if(x <= y) {
ans = arr[x-1];
}
}
cout << ans;
return 0;
}