SRM 428,429 Dynamic Programming.