最简单的dp问题
连续子数组最大和
http://www.nowcoder.com/questionTerminal/03d341fb6c9d42debcdd38d82a0a545c
#普通的DP 问题 if __name__ == "__main__": n = int(input()) l = [] for _ in range(n): l.append(int(input())) s = [0 for _ in range(n)] s[0] = l[0] ans = l[0] for i in range(1, n): if s[i-1]>0: s[i] = s[i-1] + l[i] else: s[i] = l[i] ans = max(ans, s[i]) print(ans)