greedy, dp