-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14501_ leave.py
More file actions
36 lines (29 loc) · 788 Bytes
/
14501_ leave.py
File metadata and controls
36 lines (29 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# BaekJoon 04/01 2022
# 삼성 SW 역량 테스트 기출 문제
# 14501 퇴사
n = int(input())
consultingTime = [list(map(int, input().split())) for _ in range(n)]
dp = [0] * (n+1)
for i in range(n):
if i+consultingTime[i][0] <= n:
for j in range(i+consultingTime[i][0], n+1):
dp[j] = max(dp[j], dp[i+consultingTime[i][0]], dp[i]+consultingTime[i][1])
print(dp[-1])
'''
skiped = [False for _ in range(n)]
maxResult = 0
for i in range(n):
if skiped[i]:
continue
j = i
tmp = 0
while j < n:
if j + consultingTime[j][0] <= n:
tmp += consultingTime[j][1]
skiped[j] = True
j += (consultingTime[j][0])
else:
break
maxResult = max(maxResult, tmp)
print(maxResult)
'''