[Routine] Dynamic Programming, tricky one