# BOJ - 14501 - 퇴사

Updated:

```
import sys
def solution():
N = int(input())
T = []
P = []
dp = [0 for _ in range(N)]
for _ in range(N):
t, p = map(int, sys.stdin.readline().split())
T.append(t)
P.append(p)
if T[-1] == 1:
dp[-1] = P[-1]
for i in range(N - 2, -1, -1):
day = i + T[i]
if day == N:
dp[i] = max(P[i], dp[i + 1])
elif day < N:
dp[i] = max(P[i] + dp[day], dp[i + 1])
else:
dp[i] = dp[i + 1]
print(dp[0])
solution()
```

https://www.acmicpc.net/problem/14501

## Leave a comment