알고리즘/백준풀이8. 정렬
(8) [C++] 백준 No.11004 : K번째 수
Storage Gonie
2019. 5. 19. 20:56
반응형
문제
풀이
자세한 풀이 : https://ldgeao99.tistory.com/entry/챕터5-5-정렬-문제풀이2-1
# C++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, k;
cin >> n >> k;
vector<int> v(n);
for (int i = 0; i < n; i++)
cin >> v[i];
nth_element(v.begin(), v.begin() + (k-1), v.end());
cout << v[k-1] << "\n";
}
반응형