Cod sursa(job #1390970)
| Utilizator | Data | 17 martie 2015 15:13:34 | |
|---|---|---|---|
| Problema | Statistici de ordine | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
// How about a coding trick?
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
FILE *fin=freopen("sdo.in","r",stdin);
FILE *fout=freopen("sdo.out","w",stdout);
vector <int> V;
int main()
{
int n, x, k;
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; ++i)
{
scanf("%d", &x);
V.push_back(x);
}
nth_element(V.begin(), V.begin() + k - 1, V.end());
printf("%d", V[k - 1]);
return 0;
}
