0-N Knapsack TLE

Why it is showing run time error?? while two testcases are passing

Code: https://ide.codingblocks.com/s/340576

It’s 0-1 knapsack Problem