80pts 求调
查看原帖
80pts 求调
1455258
darksea楼主2025/1/20 19:39
#include <bits/stdc++.h>
using namespace std;
long long n,cnt,cnt2;
int main() {
	cin>>n;
	long long a[n];
	for(int i = 0; i < n; i++) { 
		cin>>a[i];
    }
	long long maxx = -1,tmaxx = 0;
	for(int i = 0; i < n; i++){
		tmaxx += a[i];
			maxx = max(maxx,tmaxx);
		if(tmaxx <= 0){
			tmaxx = 0;
		}
	}
	cout<<maxx;
	return 0;
}

第二个点WA了

2025/1/20 19:39
加载中...