For this Question: You are given weights and values of N items, put some or all of these items in a knapsack of capacity W weight to get the maximum total value in the knapsack. Note that we have at most one quantity of each item.
In other words, given two integer arrays val[0..(N-1)] and wt[0..(N-1)] which represent values and weights associated with N items respectively. Also given an integer W which represents knapsack capacity, find out the maximum value subset of val[] such that sum of the weights of this subset is smaller than or equal to W. You cannot break an item, either pick the complete item, or don’t pick it (0-1 property).The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of four lines.
The first line consists of N the number of items.
The second line consists of W, the maximum capacity of the knapsack.
In the next line are N space separated positive integers denoting the values of the N items,
and in the fourth line are N space separated positive integers denoting the weights of the corresponding items.

Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 1000
1 ≤ W ≤ 1000
1 ≤ wt[i] ≤ 1000
1 ≤ v[i] ≤ 1000For each testcase, in a new line, print the maximum possible value you can get with the given conditions that you can obtain for each test case in a new line.Input:
2
3
4
1 2 3
4 5 1
3
3
1 2 3
4 5 6

Output:
3
0, I have written this Solution Code: // A Dynamic Programming based solution for 0-1 Knapsack problem 
#include<bits/stdc++.h> 
using namespace std;

// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 

// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
int i, w; 
int K[n+1][W+1]; 

// Build table K[][] in bottom up manner 
for (i = 0; i <= n; i++) 
{ 
	for (w = 0; w <= W; w++) 
	{ 
		if (i==0 || w==0) 
			K[i][w] = 0; 
		else if (wt[i-1] <= w) 
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]); 
		else
				K[i][w] = K[i-1][w]; 
	} 
} 

return K[n][W]; 
} 

int main() 
{ 
	int t;	cin >> t;
	while(t--){
		int n, w;	cin >> n >> w;
		int wt[n+1], val[n+1];
		for(int i = 0; i < n; i++)
			cin >> val[i];
		for(int i = 0; i < n; i++)
			cin >> wt[i];
		cout << knapSack(w, wt, val, n) << endl;
	}
	return 0; 
} 
, In this Programming Language: C++, Now tell me if this Code is compilable or not?