Skip to content

Commit

Permalink
Merge pull request #55 from AlgoLeadMe/14-Redish03
Browse files Browse the repository at this point in the history
14-redish03
  • Loading branch information
Redish03 authored Feb 18, 2024
2 parents 7585ca3 + 299e904 commit efeb6c6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
39 changes: 39 additions & 0 deletions Redish03/DP/12865.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <iostream>

using namespace std;

int N, K;
int dp[101][100001];
int weight[101];
int value[101];

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> N >> K;

for (int i = 1; i <= N; i++)
{
cin >> weight[i] >> value[i];
}

for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= K; j++)
{
if (j >= weight[i])
{
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight[i]] + value[i]);
}
else
{
dp[i][j] = dp[i - 1][j];
}
}
}

cout << dp[N][K];
}
3 changes: 2 additions & 1 deletion Redish03/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
| 10차시 | 2024.01.28 | DP | [내려가기](https://www.acmicpc.net/problem/2096) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/41) |
| 11차시 | 2024.01.31 | Greedy | [삼각형 만들기](https://www.acmicpc.net/problem/1448) | [#11](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/44) |
| 12차시 | 2024.02.03 | DP | [구간 합 구하기 5](https://www.acmicpc.net/problem/11660) | [#12](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/47) |
| 13차시 | 2024.02.06 | Back tracking | [N과 M(9)](https://www.acmicpc.net/problem/15663) | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/47) |
| 13차시 | 2024.02.06 | Back tracking | [N과 M(9)](https://www.acmicpc.net/problem/15663) | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/52) |
| 14차시 | 2024.02.12 | KnapSack(DP) | [평범한 배낭](https://www.acmicpc.net/problem/12865) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/55) |

---

0 comments on commit efeb6c6

Please sign in to comment.