cut rod problem in dynamic plan