Cod sursa(job #1768141)
Utilizator | Data | 30 septembrie 2016 11:48:08 | |
---|---|---|---|
Problema | Statistici de ordine | Scor | 70 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
int N,K,a[3000001];
using namespace std;
ifstream f("sdo.in");
ofstream g("sdo.out");
bool cmp(const int &x1,const int &x2)
{
return (x1<x2);
}
int main()
{
f>>N>>K;
for(int i=1;i<=N;i++)
f>>a[i];
random_shuffle(a+1,a+N+1);
nth_element(a+1,a+K,a+N+1,cmp);
g<<a[K];
return 0;
}