ans

zhaocong 2022-04-03 13:35:43 12 返回题目

#include<bits/stdc++.h>

using namespace std;

long long t,n,sum,a[10010],maxx=INT_MIN;

int main(){

scanf("%lld",&t);

while(t--){

	maxx=INT_MIN;

	sum=0;

	scanf("%lld",&n);

	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);

	for(int i=1;i<=n;i++){

		for(int j=i;j<=n;j++){

			sum+=a[j];

			maxx=max(sum,maxx);

			if(sum<=0) break;

		}

		sum=0;

	}

	printf("%lld\n",maxx);

}

return 0;

}

{{ vote && vote.total.up }}