s18-04 Dynamic programming 1