oldsix_2 @ 2023-04-09 16:45:13
sort为什么会超时?!
#include<bits/stdc++.h>
using namespace std;
long long a[11451400],n,k;
int main(){
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
cout<<a[k];
return 0;
}
by oldsix_2 @ 2023-04-09 17:14:48
@Yangbowen0108 A了,谢谢大佬
by _Hu_Tao @ 2023-04-09 17:15:32
@oldsix_2
#include<bits/stdc++.h>
using namespace std;
int a[5000001],k;
int main()
{
int n;
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n);
printf("%d",a[k]);
}
开O2提交即可
by oldsix_2 @ 2023-04-09 17:15:33
@Yangbowen0108 关注已打
by ___Yang__ @ 2023-04-09 17:16:00
@oldsix_2 不客气