# Baekjoon-15486-퇴사 2

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