Cod sursa(job #2450235)

Utilizator ejoi2019Ejoi 2019 ejoi2019 Data 22 august 2019 13:21:47
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.83 kb
#include <cstdio>
#include <algorithm>

using namespace std;

const int SEX=(1<<18);
int pbb=SEX;
char buf[SEX];

char ju()
{
        if(pbb==SEX)
        {
                pbb=0;
                fread(buf,1,SEX,stdin);
        }
        return buf[pbb++];
}

int o69()
{
        char jeg=ju();
        while(jeg==' ')
                jeg=ju();
        int num=0;
        while('0'<=jeg && jeg<='9')
        {
                num=10*num+jeg-'0';
                jeg=ju();
        }
        return num;
}

const int N=(int)3e6+7;
int n,k,a[N];

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

        n=o69();
        k=o69();
        for(int i=1;i<=n;i++) a[i]=o69();
        nth_element(a+1,a+k,a+n+1);
        printf("%d\n",a[k]);

        return 0;
}