Cod sursa(job #2341435)

Utilizator MateiAruxandeiMateiStefan MateiAruxandei Data 11 februarie 2019 20:15:24
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.79 kb
#include <cstdio>
#include <algorithm>

using namespace std;

int v[3000005];
const int buffsize = 655536;
char buffer[buffsize + 1];
int poz = buffsize;

char getCh(){
    if(poz == buffsize){
        fread(buffer, 1, buffsize, stdin);
        poz = 0;
    }
    return buffer[poz++];
}

int readInt(){
    int num = 0;
    char ch = getCh();
    while(1){
        if(ch == ' ' || ch == '\n')
            break;
        num = num * 10 + (ch - '0');
        ch = getCh();
    }
    return num;
}

int main()
{
    freopen("sdo.in", "r", stdin);
    freopen("sdo.out", "w",stdout);

    int n, k;
    n = readInt();
    k = readInt();

    for(int i = 1; i <= n; ++i)
        v[i] = readInt();

    sort(v + 1, v + n + 1);

    printf("%d\n", v[k]);
    return 0;
}