The point of this pset is to understand how floats are stored in a computer and the ramifications of that imprecise storage.  As written, your program depends on exact representation of numbers in the computer, but the very imprecision of those floats is causing your difficulties.

http://cs50.stackexchange.com/questions/13734/what-is-wrong-with-this-code-for-greedy-pset1 goes into more detail, and you should consider reviewing the class material on floats.

If this answers your question, please click on the check mark to accept. Let's keep up on forum housekeeping. ;-)