include<bits/stdc++.h>
using namespace std; int knapsack(int* weights, int* values, int n, int maxWeight){ ios_base :: sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); int i, j; int dp[maxWeight + 1]; memset(dp, 0, sizeof dp); int flag = 1; for(i = 1; i <= n; i++) { for(j = maxWeight; j >= weights[i — 1]; j--) dp[j] = max(dp[j], values[i — 1] + dp[j — weights[i — 1]]); } int ans = dp[maxWeight]; return ans; }