Can i solve it by using bitmasking?

can i solve it by using bitmasking ?? it is under bitmasking section.

no, actually this problem is Based On Dynamic Programing.

but it is under bitmasking section, how can i approach this problem?