HDU 1074 - Doing Homework

Problem : N homeworks. (N<=15). Giving a order of doing homework s.t. the total days of overdule is minimum.
Solution : Set f[i] is the minimum overdue at status i, which homework j is done if and only if 2^j AND i larger than zero. Then we get f[i]=max{ f[i']+max(0, days_taken(i)-deadline(j)) | i' XOR 2^j == i }.