greedy program from pset1 cs50