题解 | #连续子数组最大和#
连续子数组最大和
https://www.nowcoder.com/practice/1718131e719746e9a56fb29c40cc8f95
import sys n = int(input()) s = input().split() #将输入的s转化为整型 s = list(map(lambda x :int(x),s)) #创建dp列表 dp=[i for i in range(len(s))] #初始化dp0 dp[0]=s[0] #为dp列表赋值 for i in range(1,len(s)): dp[i]=max(dp[i-1]+s[i],s[i]) #print(dp) dp.sort() print(dp[-1])