Pregunta de entrevista de PDT Partners

A problem related with dynamic programming.