Cod sursa(job #1160176)

Utilizator ThomasFMI Suditu Thomas Thomas Data 30 martie 2014 12:35:47
Problema Statistici de ordine Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.31 kb
#include <fstream>
#include <algorithm>
using namespace std;

#define NMax 3000005

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

int n,k;
int v[NMax];

int main()
{
    f>>n>>k;
    for(int i=1;i<=n;i++) f>>v[i];

    nth_element(v+1,v+k,v+n+1);
    g<<v[k]<<"\n";

    f.close();
    g.close();
    return 0;
}