yet another greedy problem