why python solution is getting time limit exceeded in most of the dp problems on spoj ?