60分求助!!!

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

ptsxlhs @ 2024-04-03 09:40:09

#include<bits/stdc++.h>
using namespace std;
int a[100001];

int main(){
    int n,k;
    cin>> n >> k;
    for(int i = 1; i<=n; i++){
        cin>> a[i];
    }
    nth_element(a+1,a+1+k,a+n+1);
    cout<< a[k+1];
    return 0;
}

by schirst @ 2024-04-03 10:56:16

数组开小了


by QingDeng_Star @ 2024-04-04 10:52:40

还有,要么开快读,要么换

scanf

by ptsxlhs @ 2024-04-04 16:19:01

@jie_xusheng @xlt1 谢谢,通过了


|