Skip to content

Commit

Permalink
#17 : 2579_계단 오르기
Browse files Browse the repository at this point in the history
#17 : Week4_예원이티
  • Loading branch information
yewonahn authored May 10, 2023
1 parent 2c30414 commit de89484
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 이티예원/2579_계단 오르기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import sys
input = sys.stdin.readline

n = int(input())
score = []

This comment has been minimized.

Copy link
@plum-king

plum-king May 14, 2023

Contributor

score과 dp를 모두 0으로 채워진 리스트로 처음부터 선언해주어야 런타임 에러가 발생하지 않습니다! 그리고 for문 안에 score 리스트를 입력 받을 때에도 append 대신 인덱스를 사용하여 넣어주어야 런타임 에러가 발생하지 않습니다! 이 부분 고쳐서 다시 커밋해주세요! 문제 푸시느라 고생하셨습니다 :)

This comment has been minimized.

Copy link
@plum-king

plum-king May 14, 2023

Contributor

그리고 PR 남겨주시면 리뷰로 달아드릴 수 있어서 다음 주부터는 PR로 날려주시면 감사하겠습니다~!!

dp = []

for _ in range(n):
score.append(int(input()))

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

print(dp[n-1])

1 comment on commit de89484

@yewonahn
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2579

Please sign in to comment.