Algorithm/boj

[파이썬] 2559 수열

takeU 2022. 6. 13. 20:25
반응형
n, k = map(int, input().split())
li = list(map(int, input().split()))
dp = [sum(li[:k])]

for i in range(k, n):
    dp.append(dp[i - k] - li[i - k] + li[i])
print(max(dp))

누적 합