Cod sursa(job #2758834)

Utilizator lahayonTester lahayon Data 13 iunie 2021 11:59:21
Problema Statistici de ordine Scor 50
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include <fstream>
#include <vector>
#include <algorithm>


using namespace std;

int main()
{
    ifstream cin("sdo.in");
    ofstream cout("sdo.out");
         

    int N, K;
    cin >> N >> K;

    vector<int> A;

    for(int x; N > 0; --N){
        cin >> x;
        A.push_back(x);
    }
  
    nth_element(A.begin(), A.begin() + K, A.end());

    cout << A[K - 1];

    cin.close();
    cout.close();

    return 0;
}