根本不用这么复杂
```cpp
#include <iostream>
#include <algorithm>
using namespace std;
long long number[5000005];
int main() {
ios::sync_with_stdio(0);
int n, k;
cin >> n >> k;
for (int a = 0; a < n; a++) cin >> number[a];
sort(number, number + n);
cout << number[k];
}
``````
by HEROBRINEH @ 2024-03-05 17:41:42
@[HEROBRINEH](/user/1113507) 对呀
by dp28 @ 2024-03-05 17:42:48
@[SIRIUS0105](/user/1132339) $5 \times 10^5$ 你以为是什么概念?常数太大了(
by QWQ_123 @ 2024-03-05 17:56:40
TLE应该是因为 $n$ 是 $5e6$ 级别,数据量过大导致读写超时,可以考虑使用快读快写,如:
```cpp
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
```
但即便是这样,用桶排还是会导致MLE,因为 $a_i$ 是 $1e9$ 级别的
@[SIRIUS0105](/user/1132339)
by 杜都督 @ 2024-03-05 17:57:24
@[杜都督](/user/39279) 其实只需要将 $bnum$ 变大即可。
by QWQ_123 @ 2024-03-05 18:00:36
@[QWQ_123](/user/740328) 你说得对,我测试了一下,$bnum$ 改到 $1e4$ 就能A了
@[SIRIUS0105](/user/1132339)
by 杜都督 @ 2024-03-05 18:09:09
@[杜都督](/user/39279) 他这个是按照每 bnum 个数字分一块,然后对每一块使用快排(所以当bnum足够大就是快排,bnum足够小就是纯桶排。
所以这个东西不如直接快排(
by QWQ_123 @ 2024-03-05 18:13:54
@[QWQ_123](/user/740328) 桶排的本质就是这样嘛,这道题用来练练手,写写自己喜欢的排序也是好的(
by 杜都督 @ 2024-03-05 18:25:22
@[杜都督](/user/39279) :)
by SIRIUS0105 @ 2024-03-05 19:44:59
@[杜都督](/user/39279) 已关:)
by SIRIUS0105 @ 2024-03-05 20:05:21