Cod sursa(job #2947026)

Utilizator TheAndreiEnache Andrei Alexandru TheAndrei Data 25 noiembrie 2022 16:29:58
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include <iostream>
#include <fstream>
#include <stdlib.h>

#define nMax 3000000

using namespace std;

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

int compare (const void * a, const void * b){
  return ( *(int*)a - *(int*)b );
}

int v[nMax];

int main()
{
    int n, cautat;
    fin>> n>>cautat;

    for(int i=0;i<n;i++)
        fin>>v[i];

    qsort(v, n, sizeof(int), compare);

    fout<<v[cautat-1];
    return 0;
}