#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int dp[1000005], sum[1000005];
int main()
{
int t, n,a, b;
scanf("%d", &t);
while(t--)
{
memset(dp, 0, sizeof(dp));
dp[0]=0;
scanf("%d", &n);
for(a =1; a<=n;a++)
{
scanf("%d", & sum[a]);
dp[a]=dp[a-1]+sum[a];
}
sort(dp, dp+n+1);
int max = dp[n] - dp[0];
int min=9999;
for(b = 1; b <=n; b++)
{
if( dp[b] -dp[b-1]<min)
min = dp[b] - dp[b-1];
}
printf("%d\n", max - min);
}
return 0;
}
noj +422字串和之差
最新推荐文章于 2024-01-10 21:36:27 发布