fork(1) download
  1. #include<stdio.h>
  2. int main() {
  3. int c,n,i,t,max,sum;
  4. scanf("%d",&c);
  5. while(c--){
  6. scanf("%d",&n);
  7. max=sum=0;
  8. while(n--){
  9. scanf("%d",&t);
  10. sum+=t;
  11. if(sum<0) sum=0;
  12. else if(sum>max) max=sum;
  13. }
  14. printf("%d\n",max);
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 5636KB
stdin
3
4
1 2 3 4
3
-1 0 1
10
1 -2 28 -4 3 4 -7 2 4 -1
stdout
10
1
31