Cod sursa(job #856307)
Utilizator | Data | 16 ianuarie 2013 11:11:53 | |
---|---|---|---|
Problema | Statistici de ordine | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <cstdio>
#include <algorithm>
#include <fstream>
const int maxn = 3000005;
using namespace std;
int A[maxn], n, k;
int main() {
ifstream fin("sdo.in");
ofstream fout("sdo.out");
fin >> n >> k;
for( int i = 1; i <= n; ++i)
fin >> A[i];
random_shuffle(A + 1, A + n + 1);
nth_element(A + 1, A + k, A + n + 1);
fout << A[k];
return 0;
}