Pagini recente » Cod sursa (job #1361071) | Cod sursa (job #273956) | Cod sursa (job #1954871) | Cod sursa (job #1770199) | Cod sursa (job #524244)
Cod sursa(job #524244)
#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;
}