3AC,2RE?

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

LRXXXM @ 2021-10-11 14:28:14

最后俩点RE了

#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
ll n,a[100000],m;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++){
            cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[m];
    return 0;
}

by Onana_in_XMFLS @ 2021-10-11 14:28:33

数组开大点


by LRXXXM @ 2021-10-11 14:29:26

怎么就错了捏?


by LRXXXM @ 2021-10-11 14:31:25

3AC,2TLE


by LRXXXM @ 2021-10-11 14:31:44

#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
ll n,a[100000000],m;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++){
            cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[m];
    return 0;
}

by Novice233 @ 2021-10-11 14:33:12

@LRXXXM 你猜一道普及难度的题目只用sort够吗


by LRXXXM @ 2021-10-11 14:34:45

@JR_Stark 题解也这样说的啊


by Novice233 @ 2021-10-11 14:36:08

@LRXXXM sort绝对满不了啊 你自己看数据范围 这是OIer基本品质吧


by LRXXXM @ 2021-10-11 14:37:53

@JR_Stark 好吧,我是傻逼


by _8762 @ 2021-10-11 14:43:19

@LRXXXM 你这个都是从1开始存的呀


by the_shadow @ 2021-10-11 15:50:54

@LRXXXM 开o2,数组开大点再加上输入输出scanf和printf,就过了


|