use greedy instead of dp