A dynamic programming-based approach for cloud instance type selection and optimisation