Pagini recente » Cod sursa (job #2439770) | Cod sursa (job #2329635) | Cod sursa (job #464588) | Cod sursa (job #3332227) | Cod sursa (job #3326412)
#include <bits/stdc++.h>
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/* /\ _____ _____ _______ /\ |\ |
/ \ | | \ / / | / \ | \ |
/----\ | |-- \/ \_____ | /----\ | \ |
/ \ | | /\ \ | / \ | \ |
/ \ |____ |____ / \ ______/ | / \ | \| */
using namespace std;
ifstream fin ("sdo.in");
ofstream fout ("sdo.out");
int n, k;
int a[3000005];
void merg(int l, int m, int r){
int i = l;
int j = m;
vector <int> rez;
while(i < m || j <= r){
if((a[i] < a[j] && i < m) || j > r){
rez.push_back(a[i]);
i++;
}
else if(j <= r){
rez.push_back(a[j]);
j++;
}
}
for(int i = 0; i < rez.size(); i++){
a[l+i] = rez[i];
}
}
void mergsort(int l, int r){
//cout << l << " " << r << "\n";
if(l < r){
mergsort(l, (l + r) / 2);
mergsort((l + r) / 2 + 1, r);
merg(l, (l + r) / 2 + 1, r);
}
}
int main()
{
fin >> n >> k;
for(int i = 1; i <= n; i++){
fin >> a[i];
}
mergsort(1, n);
fout << a[k];
return 0;
}