#include <iostream>
#include <climits>
using namespace std;
int knapSack(int v[], int w[], int n, int W)
{
    if (W < 0)
        return INT_MIN;
    if (n < 0 || W == 0)
        return 0;
    int in = v[n] + knapSack(v, w, n - 1, W - w[n]);
    int ex = knapSack(v, w, n - 1, W);
    return max(in, ex);
}
int main()
{
    int v[] = {1, 6, 18};
    int w[] = {1, 2, 5};
    int W = 11;
    int n = sizeof(v) / sizeof(v[0]);
    cout << "Knapsack value is " << knapSack(v, w, n - 1, W);
    return 0;
}