K-D²

백준 11004 본문

Algorithm/BOJ

백준 11004

K.Scrt.D 2021. 2. 4. 10:08
#include <bits/stdc++.h>
using namespace std;

int N, K;
int num[5000005];
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> N >> K;
    for (int i = 0; i != N; ++i) {
        cin >> num[i];
    }
    nth_element(num, num + K - 1, num + N);
    cout << num[K - 1];
    return 0;
}

 

'Algorithm > BOJ' 카테고리의 다른 글

1247  (0) 2021.03.08
1246  (0) 2021.02.19
1245  (0) 2021.02.01
1244  (0) 2021.01.28
1243  (0) 2021.01.27
Comments