为什么本地运行不了交上去AC

B4066 [GESP202412 三级] 数字替换

username____ @ 2024-12-28 16:13:30

rt

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n, nums[10000000], k;
    cin >> n >> k;
    int mxa, mna; 
    for(int i = 0 ; i < n ; i ++){
        cin >> nums[i];
        mxa = max(nums[i], mxa);
        mna = min(nums[i], mna);
    }

    for(int i = 0 ; i < n ;i ++){
        if(nums[i] < k) {
            nums[i] = mna;
        } else if (nums[i] > k){
            nums[i] = mxa;
        }
        cout << nums[i] << " ";
    }

    return 0;
}

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


by JmBecca @ 2024-12-28 16:18:44

@username____nums数组太大了,删多两个0就好了


by xlpri @ 2024-12-28 16:25:58

可以运行,可能是你的电脑里不支持

nums[10000000]

这么大的数组,可以把它放到main函数外面试试


by username____ @ 2024-12-28 16:34:15

收到


|