Cod sursa(job #1650269)
| Utilizator | Data | 11 martie 2016 17:30:52 | |
|---|---|---|---|
| Problema | Statistici de ordine | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
# include <fstream>
# include <algorithm>
# include <vector>
# define foreach(A) for(int i=1; i<=(A); ++i)
using namespace std;
ifstream fin("sdo.in");
ofstream fout("sdo.out");
const int MAXN = 3000005;
vector<int> V;
int N, K;
int main() {
int x;
fin >> N >> K;
foreach(N) {
fin >> x;
V.push_back(x);
}
vector<int>::iterator it = V.begin();
it += (K-1);
nth_element(V.begin(), it, V.end());
fout << V[K-1];
return 0;
}
