completed greedy problem