Zzy20060323 @ 2024-09-24 00:04:02
#include<stdio.h>
#include<stdlib.h>
int a[5000005];
int n, k;
int cmp(const void* a, const void* b)
{
return *(int*)a - *(int*)b;
}
int main()
{
scanf("%d%d", &n, &k);
for (int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
qsort(a, n, sizeof(int), cmp);
printf("%d", a[k]);
return 0;
}
by Air_Color5 @ 2024-09-24 00:11:47
5e6 跑不过单 log ,这并不妨碍你写 &(1<<16) 的基数排序
by Zzy20060323 @ 2024-09-24 07:45:27
@Air_Color5 我是小白,听不懂。。。
by Affordan @ 2024-09-24 10:52:30
我用priority_queue时间也超了,这题说是要二分估计就得用Log(N)的算法了,QWQ。
by Air_Color5 @ 2024-09-24 15:57:02
@Zzy20060323 请自学
by vintces @ 2024-10-06 00:50:52
我tm这样居然全ac了()
#include <bits/stdc++.h>
using namespace std;
int ls[5000000];
int n, k;
int main() {
cin >> n >> k;
for (int i = 0; i < n; i++) {
scanf("%d", &ls[i]);
}
sort(ls, ls + n);
printf("%d\n", ls[k]);
}
神经啊