Pagini recente » Cod sursa (job #1408385) | Cod sursa (job #2157652) | Cod sursa (job #318769) | Cod sursa (job #42203) | Cod sursa (job #2450663)
#include <bits/stdc++.h>
using namespace std;
FILE * fin = fopen("sdo.in", "r");
const int N_MAX = 3000005;
const int buffer = 100000;
int N, K;
char buff[buffer];
int Array[N_MAX];
int pos;
void readBuffer() {
fread(buff, sizeof(char), buffer, fin);
}
char readChar() {
++pos;
if (pos == buffer) {
readBuffer();
pos = 0;
}
return buff[pos];
}
int readInt() {
char c;
while (!isdigit(c = readChar())) ;
int ans = 0;
while (isdigit(c)) {
ans = 10 * ans + (c - '0');
c = readChar();
}
return ans;
}
int main() {
freopen("sdo.out", "w", stdout);
N = readInt();
K = readInt();
for (int i = 1; i <= N; ++i) {
Array[i] = readInt();
}
nth_element(Array + 1, Array + K + 1, Array + N + 1);
cout << Array[K];
return 0;
}