Cod sursa(job #524244)

Utilizator andrei.dAndrei Diaconeasa andrei.d Data 20 ianuarie 2011 19:24:31
Problema Statistici de ordine Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.68 kb
#include <cstdio>
#include <algorithm>

using namespace std;

#define file_in "sdo.in"
#define file_out "sdo.out"

int N,K,i;
int V[3100000];

#define dim 8192
char ax[dim];
int pz;

inline void cit (int &x)
{
	x = 0;
	while (ax[pz] < '0' || ax[pz] > '9')
		if (++pz == dim)
			fread (ax, 1, dim, stdin), pz = 0;

	while (ax[pz] >= '0' && ax[pz] <= '9')
	{
		x = x * 10 + ax[pz] - '0';
		if (++pz == dim)
			fread (ax, 1, dim, stdin), pz = 0;
	}
}


int main(){
	
	freopen(file_in,"r",stdin);
	freopen(file_out,"w",stdout);
	
	cit(N);
	cit(K);
	for (i=1;i<=N;++i)
		 cit(V[i]);
	
	nth_element(V+1,V+K,V+N+1);
	
	printf("%d\n", V[K]);
	
	return 0;
	
}