动态规划
连续子数组最大和
http://www.nowcoder.com/questionTerminal/03d341fb6c9d42debcdd38d82a0a545c
""" 动态规划,连续子序列的最大和 dp[i]为i为结束点的子序列最大和 """ if __name__ == '__main__': n = int(input()) a = [] for _ in range(n): a.append(int(input())) dp = [a[0]] for i in range(1, n): dp.append(max(0, dp[-1]) + a[i]) print(max(dp))