题目描述
给你一个长度为n的序列,求序列中第k小数的多少。
n <= 2e6
- 快排求 K K K大值
- s t d : : n t h _ e l e m e n t std::nth\_element std::nth_element
Q = read();
while(Q--) {
n = read(), K = read();
for(int i=0; i<n; i++) a[i] = read();
std::nth_element(a, a+K-1, a+n);
printf("%d\n", a[K-1]);
}