Pagini recente » Cod sursa (job #2975196) | Cod sursa (job #2969777)
#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;
}