Skip to content

Commit

Permalink
개미 전사 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezidayzi committed Mar 6, 2022
1 parent 53ec81e commit f1296b4
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys
n = int(sys.stdin.readline().rstrip())
array = list(map(int, sys.stdin.readline().split()))

d = [0] * (n+1)
d[1] = array[0]
d[2] = max(d[1], array[1])

for x in range(3, n+1):
d[n] = max(d[n-1], d[n-2]+array[n-1])

print(d[n])

0 comments on commit f1296b4

Please sign in to comment.