Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.

Commit a3e09a0

Browse files
committed
20210707
1 parent 43f66f3 commit a3e09a0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
n = int(input())
5+
arr = [[0, 0]]
6+
for _ in range(n-1):
7+
arr.append(list(map(int, input().split())))
8+
k = int(input())
9+
10+
dp = [[100000, 100000] for _ in range(n+1)]
11+
dp[1][0] = 0
12+
if n > 1:
13+
dp[2][0] = arr[1][0] # 큰 점프가 불가능할때
14+
if n > 2:
15+
dp[3][0] = min(dp[2][0] + arr[2][0], arr[1][1]) # 매우 큰점프가 불가능할떄
16+
for i in range(4, n+1):
17+
dp[i][0] = min(dp[i-1][0] + arr[i-1][0], dp[i-2][0] + arr[i-2][1]) # 매우 큰점프 사용 x
18+
dp[i][1] = min(dp[i-3][0] + k, dp[i-2][1] + arr[i-2][1], dp[i-1][1] + arr[i-1][0]) # 매우 큰점프 사용
19+
20+
print(min(dp[n]))

0 commit comments

Comments
 (0)