Hey all! The problem doesn't look much difficult, It is easily reduced to a knapsack problem. But I got a strange problem with it! the code below gets: Idleness limit exceeded on test 9 The code: http://paste.ubuntu.com/5673644/ I've shown my problem to some people but no body understood what's the problem. CAN ANYBODY HELP!!!!