Skip to content

Commit de89c53

Browse files
committed
[BOJ] 수강 과목 / 골드 5 / 40분
https://www.acmicpc.net/problem/17845
1 parent b1bf6ed commit de89c53

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
N, K = map(int, input().split())
2+
arr = [0]
3+
dp = [[0] * (N + 1) for _ in range(K + 1)]
4+
5+
for i in range(K):
6+
importance, time = map(int, input().split())
7+
arr.append([importance, time])
8+
9+
for i in range(K+1):
10+
for j in range(N+1):
11+
if i == 0 or j == 0:
12+
continue
13+
14+
importance, time = arr[i]
15+
if time > j:
16+
dp[i][j] = dp[i - 1][j]
17+
else:
18+
dp[i][j] = max(importance + dp[i - 1][j - time], dp[i - 1][j])
19+
20+
print(dp[K][N])

0 commit comments

Comments
 (0)