Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int sum[105],max[105],n1,n2,temp,count=0,i;
- for(scanf("%d",&n1);n1>=1;n1--)
- {
- for(scanf("%d",&n2);n2>=1;n2--)scanf("%d",&sum[count++]);
- max[0]=sum[0];
- temp=sum[0];
- for(i=1;i<count;i++)
- {
- (temp<0)&&(temp=0);
- temp+=sum[i];
- sum[i]=temp;
- (max[i-1]>=sum[i])?max[i]=max[i-1]:(max[i]=sum[i]);
- }
- printf("%d\n",max[i-1]);
- count=0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement