Cod sursa(job #2589146)

Utilizator k2e0e0w3qDumitrescu Gheorghe k2e0e0w3q Data 25 martie 2020 20:37:16
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 kb
#include <bits/stdc++.h>
using namespace std;

int main () {
    ifstream fin ("sdo.in");
    ofstream fout ("sdo.out");
    ios::sync_with_stdio(false);

    vector <int> v;
    int n, k, x;
    fin >> n >> k;
    for (; n; n--) {
        fin >> x;
        v.push_back(x);
    }
    fin.close();

    --k;
    nth_element(v.begin(), v.begin()+k, v.end());
    fout << v[k];
    fout.close();
    return 0;
}