Cod sursa(job #2471753)

Utilizator MatteoalexandruMatteo Verzotti Matteoalexandru Data 11 octombrie 2019 13:20:14
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.35 kb
/*
                `-/oo+/-   ``
              .oyhhhhhhyo.`od
             +hhhhyyoooos. h/
            +hhyso++oosy- /s
           .yoooossyyo:``-y`
            ..----.` ``.-/+:.`
                   `````..-::/.
                  `..```.-::///`
                 `-.....--::::/:
                `.......--::////:
               `...`....---:::://:
             `......``..--:::::///:`
            `---.......--:::::////+/`
            ----------::::::/::///++:
            ----:---:::::///////////:`
            .----::::::////////////:-`
            `----::::::::::/::::::::-
             `.-----:::::::::::::::-
               ...----:::::::::/:-`
                 `.---::/+osss+:`
                   ``.:://///-.
*/
#include <fstream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <cmath>
#define INF 0x3f3f3f3f
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

using namespace std;

int v[3000005];

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

int main()
{
    //freopen("sdo.in","r",stdin);
    //freopen("sdo.out","w",stdout);
    int n, k;
    in >> n >> k;
    for(int i = 1; i <= n; i++) in >> v[i];
    nth_element(v + 1, v + k, v + n + 1);
    out << v[k] << '\n';
    return 0;
}