Cod sursa(job #1380259)

Utilizator hopingsteamMatraguna Mihai-Alexandru hopingsteam Data 7 martie 2015 04:47:06
Problema Statistici de ordine Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.48 kb
#include    <algorithm>
#include    <iostream>
#include    <fstream>
#include    <vector>

using namespace std;

ifstream fin("sdo.in");
ofstream fout("sdo.out");

vector < int > V;

int N, poz;
void Read()
{
    fin >> N >> poz;
    poz -= 1;
    for(int i = 1; i <= N; i++)
    {
        int x;
        fin >> x;
        V.push_back(x);
    }
    nth_element(V.begin(), V.begin + poz, V.end());
    fout << V[poz];
}

int main()
{
    Read();
    return 0;
}