Cod sursa(job #430449)

Utilizator slayer4uVictor Popescu slayer4u Data 31 martie 2010 01:04:54
Problema Statistici de ordine Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb
#include <cstdio>
#include <algorithm>
using namespace std;

#define NMAX 3000050

long n, k, x[NMAX];
int main()
{
	freopen ("sdo.in", "rt", stdin);
	freopen ("sdo.out", "wt", stdout);

	scanf("%ld %ld", &n, &k);
	for (long i = 1; i <= n; ++i)
		scanf("%ld", &x[i]);

	nth_element(x + 1, x + k, x + n + 1);

	printf("%ld\n", x[k]);

	return 0;
}