Pagini recente » Cod sursa (job #1130775) | Cod sursa (job #2814832) | Cod sursa (job #2980049) | Cod sursa (job #1120585) | Cod sursa (job #2823196)
#include <bits/stdc++.h>
using namespace std;
int main(){
ifstream cin("sdo.in");
ofstream cout("sdo.out");
int n, k;
cin >> n >> k;
vector<int> v(n);
for(int i = 0; i < n; ++i){
cin >> v[i];
}
priority_queue<int> maxHeap;
for(int val: v){
maxHeap.push(val);
if((int)maxHeap.size() > k){
maxHeap.pop();
}
}
cout << maxHeap.top();
cin.close();
cout.close();
return 0;
}