The Trip Programming challenge UVA10137
Printing loses precision

Using this input file:

6
0 0 0 0 10000 10000


Your program gives this answer:


$13333.3



The actual answer should be $13333.32.  The program seemed correct, but the printing only printed out 6 digits of precision.  I made this change to your program which made it print out the correct answer:

cout.precision(15);


Better to use integers

It would be safer to use integers throughout your program.  There could be any number of floating point roundoff problems that might show up unexpectedly, especially since 0.01 is not perfectly representable by a double.