Cod sursa(job #2717447)

Utilizator AACthAirinei Andrei Cristian AACth Data 7 martie 2021 14:10:46
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.55 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("sdo.in");
ofstream g("sdo.out");
vector < int > v;
void nos()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int n,k;
void read()
{
    f>>n>>k;
    int i;
    for(i=1;i<=n;i++)
    {
        int x;
        f>>x;
        v.push_back(x);
    }
}
void solve()
{
    nth_element(v.begin(),v.begin()+k-1,v.end());
    g<<v[k-1];
}
void restart()
{

}

int32_t main()
{
    nos();

        read();
        solve();
        restart();

    return 0;
}