Cod sursa(job #2700968)

Utilizator cyg_mihaizMIHAI ZARAFIU cyg_mihaiz Data 29 ianuarie 2021 14:46:27
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include <fstream>
#include <algorithm>
#include <vector>

using namespace std;

ifstream fin("sdo.in");
ofstream fout("sdo.out");

vector<int> v;

int main()
{
    ios_base::sync_with_stdio(false);
    fin.tie(NULL);

    int n,k,i,x;
    fin >> n >> k;
    for(i = 1; i <= n; i++)
    {
        fin >> x;
        v.push_back(x);
    }
    nth_element(v.begin(),v.begin() + k - 1,v.end());
    fout << v[k - 1];
    return 0;
}