离谱
查看原帖
离谱
1229013
Mr_LiuXinan楼主2024/3/6 20:20

仔细比对了题解的代码和我的代码,发现没什么区别,怎么我的只有40分

#include <iostream>
using namespace std;

long long n, arr[30000], b[30000], maxx = -9999999;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> arr[i];
        b[i] = max(arr[i], b[i - 1] + arr[i]);
        maxx = max(b[i], maxx);
    }

    cout << maxx;

    return 0;
}
2024/3/6 20:20
加载中...