simple greedy algorithm