Skip to content

Commit 4f79ad0

Browse files
committed
[BOJ] 계단 오르기 / 실버 3 / 50분
https://www.acmicpc.net/problem/2579
1 parent 081bbf0 commit 4f79ad0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
N = int(input())
2+
3+
dp = [0] * (N+1)
4+
point = [0] * (N+1)
5+
for i in range(1, N+1):
6+
point[i] = int(input())
7+
if N==1:
8+
print(point[1])
9+
exit()
10+
elif N==2:
11+
print(sum(point[:3]))
12+
exit()
13+
dp[1] = point[1]
14+
dp[2] = point[1]+point[2]
15+
for i in range(3, N+1):
16+
dp[i] = max(dp[i-2]+point[i], dp[i-3]+point[i-1]+point[i])
17+
18+
print(dp[-1])

0 commit comments

Comments
 (0)