Cod sursa(job #2607733)
Utilizator | Dragomir Robert. RobertLearnsC | Data | 30 aprilie 2020 09:39:04 |
---|---|---|---|
Problema | Statistici de ordine | Scor | 60 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.53 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("sdo.in");
ofstream out("sdo.out");
int n , nthElement, element;
priority_queue<int,vector<long long>,greater<int>> v;
int main(){
in >> n >> nthElement;
for(int i = 0 ; i < n ; ++i) {
in >> element;
v.push(element);
}
int i = 0;
while(v.size()) {
if(i == nthElement - 1) {
out << v.top();
return 0;
} else {
v.pop();
++i;
}
}
return 0;
}