getting Runtime Error for knapsack problem.

I am new to competitive programming and am having difficulties in finding what can be the possible runtime errors for this question.
Here is my solution: CodeChef: Practical coding for everyone
I’ll be really grateful if someone helps. :slight_smile: