Cod sursa(job #2568218)

Utilizator NotTheBatmanBruce Wayne NotTheBatman Data 3 martie 2020 21:28:58
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 3e6 + 5;
int a[N];

void Read ()
{
    ifstream fin ("sdo.in");
    ofstream fout ("sdo.out");
    int n, k;
    fin >> n >> k;
    for (int i = 1; i <= n; i++)
        fin >> a[i];
    nth_element(a + 1, a + k, a + n + 1);
    fout << a[k] << "\n";
    fout.close();
}

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