Cod sursa(job #2306267)

Utilizator MaxTeoTeo Oprescu MaxTeo Data 21 decembrie 2018 21:00:59
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.38 kb
#include <bits/stdc++.h>
using namespace std;

ifstream f("sdo.in");
ofstream g("sdo.out");

//const int MAX = 5e5 + 5;

int k, n;
vector <int> v;

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