Skip to content

Commit 766cffe

Browse files
committed
[BOJ] #2579. 계단오르기 / 실버3 / 70분(실패)
1 parent 930a362 commit 766cffe

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
n = int(input())
5+
stair = [0]*301
6+
for i in range(n):
7+
stair[i]=int(input())
8+
9+
DP = [0]*301
10+
DP[0] = stair[0]
11+
DP[1] = stair[0]+stair[1]
12+
DP[2] = max(stair[0]+stair[2], stair[1]+stair[2])
13+
14+
for i in range(3, n):
15+
DP[i] = max(DP[i-3] + stair[i-1] + stair[i], DP[i-2]+stair[i])
16+
17+
print(DP[n-1])

0 commit comments

Comments
 (0)