-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempCodeRunnerFile.cpp
More file actions
32 lines (29 loc) · 828 Bytes
/
tempCodeRunnerFile.cpp
File metadata and controls
32 lines (29 loc) · 828 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
// int unboundedKnapsack(vector<int> val, vector<int> wt, int W, int n)
// {
// vector<vector<int>> dp(n + 1, vector<int>(W + 1, 0));
// for (int i = 1; i < n + 1; i++)
// {
// for (int j = 1; j < W + 1; j++)
// {
// int itemVal = val[i - 1];
// int itemWt = wt[i - 1];
// if (itemWt <= j)
// {
// dp[i][j] = max(itemVal + dp[i][j - itemWt], dp[i - 1][j]);
// }
// else
// {
// dp[i][j] = dp[i - 1][j];
// }
// }
// }
// return dp[n][W];
// }
// int main()
// {
// vector<int> val = {15, 14, 10, 45, 30};
// vector<int> wt = {2, 5, 1, 3, 4};
// int w = 7;
// int n = 5;
// cout << unboundedKnapsack(val, wt, w, n) << endl;//100
// }