Cu_lly888_6_5_A6 @ 2024-10-13 13:36:20
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c[1000000005];
cin>>a>>b;
for(int i=1 ; i<=a ; i++){
cin>>c[i];
}
sort(c,c+a+1);
cout<<c[b+1];
return 0;
}
这题直接快排有两个点超时,要用桶排吗
by Moco_jof @ 2024-10-13 13:47:36
要用二分
by Moco_jof @ 2024-10-13 13:50:58
哦,我手写的
by Moco_jof @ 2024-10-13 13:51:24
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long a,b,c[1000000005];
cin>>a>>b;
for(int i=1 ; i<=a ; i++){
cin>>c[i];
}
sort(c,c+a+1);
cout<<c[b+1];
return 0;
}
by Moco_jof @ 2024-10-13 13:51:55
关闭一下输出流能AC
by Moco_jof @ 2024-10-13 13:52:43
或者你用scanf和printf
by Moco_jof @ 2024-10-13 13:53:16
或者用快读快写
by Cu_lly888_6_5_A6 @ 2024-10-13 18:55:27
@Moco_jof ok谢谢