Cod sursa(job #2306270)

Utilizator mihailescu_eduardMihailescu Eduard-Florin mihailescu_eduard Data 21 decembrie 2018 21:02:40
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include <fstream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

static const int NMAX = 5e5+5;

ifstream fin("sdo.in");
ofstream fout("sdo.out");
int n, k;
vector<int> v;

int main()
{
    fin >> n >> k;
    int x;
    for(int 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;
}