Cod sursa(job #2589156)

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

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

    int n, k, *v, i;
    fin >> n >> k;
    v=new int[n];
    for (i=0; i<n; i++)
        fin >> v[i];
    fin.close();

    --k;
    nth_element(&v[0], &v[k], &v[n]);
    fout << v[k];
    fout.close();
    return 0;
}