Skip to content

Commit

Permalink
[boj] 11052 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
haremeat committed Dec 6, 2021
1 parent 64cf333 commit 02e355f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions boj/11052.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

import sys
n = int(sys.stdin.readline())
cards = list(map(int, sys.stdin.readline().split()))
cards = [0] + list(map(int, sys.stdin.readline().split()))
dp = [0] * (n + 1)


dp[1] = cards[0]
dp[2] = max(cards[0] + cards[1], cards[0])
dp[1] = cards[1]

for i in range(3, n + 1):
for i in range(2, n + 1):
for j in range(1, i + 1):
dp[i] = max(dp[i], dp[i - j] + cards[i])

dp[i] = max(dp[i], dp[i-j] + cards[j])

print(dp[n])

0 comments on commit 02e355f

Please sign in to comment.