Skip to content

Commit 6d6777e

Browse files
committed
[BOJ] #14501. 퇴사 / 실버3 / 27분 / 성공
1 parent 25c8650 commit 6d6777e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
# 초기화
5+
N = int(input()) # 남은 날짜
6+
t = [0] * (N+1) # 걸리는 기간 리스트
7+
p = [0] * (N+1) # 상담 금액 리스트
8+
dp = [0] * (N+1) # DP
9+
for i in range(1, N+1):
10+
t[i], p[i] = map(int, input().split())
11+
12+
# DP 채우기
13+
for i in range(1, N+1):
14+
time, pay = t[i], p[i]
15+
day = i + time - 1
16+
dp[i] = max(dp[i], dp[i-1])
17+
if day <= N:
18+
dp[day] = max(dp[day], dp[i - 1] + pay)
19+
print(dp[-1])

0 commit comments

Comments
 (0)