WA in knapsack problem

This post was flagged by the community and is temporarily hidden.

No you are wrong. The aim of the question is to spend the maximum amount of money that is strictly less than the alloted amount while having the most fun. A classical knapsack problem.
The algorithm is as follows assuming u have p parties and n is the maximum amount of money you can spend create a 2D array or vector v. now v(i,j) refers to the maximum fun you can have within the first i parties and with spending exactly j money.
now v[i+1][j]=Max(v[i][j],v[i][j-costof(i+1) party]]+fun in i th party]) . Provided the admission fee in i+1 party is less than n.
Now the answer to the question is the maximum of v[n-1][j] where j varies from 0 to n-1.
For more reference refer here.

This post was flagged by the community and is temporarily hidden.