Profit maximization program in python. Method 1: Dynamic Programming.