Problem 01knapsack
User j0ashhh
Submission Time 2026-02-20 16:15:54
Score 0
Max Time N/A
Max Memory N/A

Compile Error

01knapsack.cpp: In function ‘int knapsack(int, std::vector<int>, std::vector<int>)’:
01knapsack.cpp:9:10: error: expected primary-expression before ‘]’ token
9 | dp[i[][j] = 0;
| ^
01knapsack.cpp:9:18: error: expected ‘]’ before ‘;’ token
9 | dp[i[][j] = 0;
| ^
| ]
01knapsack.cpp:13:35: error: ‘wt’ was not declared in this scope
13 | pick = vals[i-1] + dp[i-1][j-wt[i-1]];
| ^~
01knapsack.cpp:20:13: error: ‘i’ was not declared in this scope
20 | cout << dp[i][j];
| ^
01knapsack.cpp:20:16: error: ‘j’ was not declared in this scope
20 | cout << dp[i][j];
| ^
01knapsack.cpp: In function ‘int main()’:
01knapsack.cpp:28:10: error: ‘weights’ was not declared in this scope; did you mean ‘weight’?
28 | cin >> weights[i] >> vals[i