[DP3] Consulting algorithm (1 pt) [00QR]

Describe an efficient algorithm that takes values for n, M, and sequences of operating costs N_1, \dots , N_n and S_1, \dots , S_n, and returns the cost of an optimal plan. Justify the correctness of your algorithm and analyze its asymptotic running time.