Cod sursa(job #2969777)

Utilizator Dragono63Stanciu Rares Stefan Dragono63 Data 23 ianuarie 2023 18:14:53
Problema Statistici de ordine Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.05 kb
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
using ll = long long;
using ci = const int;
using cll = const long long;

using namespace std;

/*******************************/
// INPUT / OUTPUT

ifstream f("sdo.in");
ofstream g("sdo.out");
/*******************************/
/// GLOBAL DECLARATIONS

int N, K;
vector <int> v;
/*******************************/
/// FUNCTIONS

void ReadInput();
void Solution();
void Output();
/*******************************/
///-------------------------------------
inline void ReadInput()
{
    f >> N >> K;
    
    -- K;
    int x;
    for (int i = 0 ; i < N ; ++ i)
    {
        f >> x;
        v.push_back(x);
    }
}
///-------------------------------------
inline void Solution()
{
    nth_element(v.begin(), v.begin() + K, v.end());
}
///-------------------------------------
inline void Output()
{
    g << v[K];
}
///-------------------------------------
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ReadInput();
    Solution();
    Output();
    return 0;
}