[1912번] 연속합
·
Coding Test/DP
1912번: 연속합 첫째 줄에 정수 n(1 ≤ n ≤ 100,000)이 주어지고 둘째 줄에는 n개의 정수로 이루어진 수열이 주어진다. 수는 -1,000보다 크거나 같고, 1,000보다 작거나 같은 정수이다. www.acmicpc.net 풀이 n = int(input()) list = list(map(int, input().split())) dp = [0] * n # 최대 연속합 dp[0] = list[0] for i in range(1, n): dp[i] = max(list[i], dp[i-1]+list[i]) # list[i] / 이전최대연속합 + list[i] # print(dp) print(max(dp))