math n k math time dp solution improved math n k log k math time binary searching optimal math x math recurrence since math w n x math increasing math x math math w nk x math decreasing math x math thus local minimum math max w n x w nk x math global minimum also storing optimal math x math cell dp table referring value previous cell optimal math x math cell found constant time improving math n k math time however
Applied science Transportation Operations research Dynamic programming