def s(arry):
tem = 0
res = arry[0]
//n =[]
for i in range(len(arry)):
if tem+arry[i] <0:
tem = 0
else:
tem += arry[i]
// n.append(arry[i])
res = max(res,tem)
// print(n)
print(res)
s([1,-2,3,10,-4,7,2,-5])
02-02
2512
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-14
868
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-07
210
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-14
97
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-03
156
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)