Dynamic programming/MCM Dp