more simple algorithm, using greed.