What is the logic behind this dynamic programming problem from Topcoder ?
I am trying to solve Topcoder problem.In editorial it is given the solution uses bitmask technique. Any one please explain the logic behind this problem.