Cod sursa(job #739121)
| Utilizator | Data | 22 aprilie 2012 10:50:27 | |
|---|---|---|---|
| Problema | Statistici de ordine | Scor | 60 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
vector<int>h;
int n,k;
bool cmp(int a,int b){ return a>b; }
int main(){
int x;
freopen("sdo.in","r",stdin);
freopen("sdo.out","w",stdout);
scanf("%d %d",&n,&k);
for(int i=1;i<=n;i++){
scanf("%d",&x);
h.push_back(x);
push_heap(h.begin(),h.end(),cmp); }
for(int i=1;i<k;i++){
pop_heap(h.begin(),h.end(),cmp);
h.pop_back();}
printf("%d\n",h[0]);
}
