Skip to content

Commit

Permalink
10-wnsmir
Browse files Browse the repository at this point in the history
  • Loading branch information
wnsmir committed Nov 30, 2024
1 parent 0dc3905 commit e288bf1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions wnsmir/DP/๊ฐœ๋ฏธ์ „์‚ฌ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
N = int(input())

Food = list(map(int, input().split()))

dp = [0]*(N+1)
dp[1] = Food[0]
dp[2] = max(Food[0], Food[1])

for i in range(4, N+1):
dp[i] = max(dp[i-2]+Food[i-1], dp[i-1])

print(dp[N])

0 comments on commit e288bf1

Please sign in to comment.