Cod sursa(job #3201888)
Utilizator | Broscoi Mihai fortyfor | Data | 10 februarie 2024 09:35:49 |
---|---|---|---|
Problema | Statistici de ordine | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.53 kb |
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <climits>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
std::vector<int> numbers;
std::ifstream fin("sdo.in");
std::ofstream fout("sdo.out");
int main()
{
int n,k,x;
fin >> n >> k;
numbers.reserve(n);
for (int i=0;i<n;i++)
{
fin >> x;
numbers.push_back(x);
}
std::nth_element(numbers.begin(), numbers.begin()+k, numbers.end());
fout << numbers[k-1];
return 0;
}