0-1 Knapsack Run time error

Two testcases are passign while rest are showing runtime error . Why so?
Code: https://ide.codingblocks.com/s/340576

Constraints are high. n and s can be upto 1000. So update the size of your dp array to 1001X1001.