private void knapsack(int n, int capacity, int w[], int v[])
	{
		for (int c = 1; c <= capacity; c++) // From the smallest subproblem to
							 				// the
											// biggest
		{
			int max = 0;
			for (int i = 0; i < n; i++)
			{
				if (capacity - w[i] >= 0 && c - w[i] >= 0)
					if (v[i] + knap[c - w[i]] > max)
						max = v[i] + knap[c - w[i]];
			}
			knap[c] = max;
		}
	}