60求助

P1923 【深基9.例4】求第 k 小的数

Orange1015 @ 2022-05-14 10:26:10

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,a[5000005]={};
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> a[i];
    nth_element(a,a+k,a+n);
    cout << a[k];
    return 0;
}

https://www.luogu.com.cn/record/75679061


by Eason2009 @ 2022-05-14 10:31:21

@Orange1015 把

cin/cout

换成

scanf/printf

或快读快写


by Eason2009 @ 2022-05-14 10:31:52

现在回贴还得用markdown把代码框上,真麻烦


by Orange1015 @ 2022-05-14 10:57:16

谢谢dalao伸手救援!


|