Page 1 of 1

10137 the Trip has some new test case

Posted: Sun Feb 09, 2014 6:55 pm
by anthonyhl

Code: Select all

4
0.01
0.05
0.05
0.07
programme should return
$0.03
there are four students each spent 0.04(0.01+0.03), 0.04(0.05-0.01), 0.05 and 0.05(0.07-0.02) respectivily.

I found most of answers calculated the diff between average and each student' cost, like this

Code: Select all

if (average > students[i]) 
   debit += average - students[i];
else 
   refund += student[i] - average;

if (debit > refund) return refund;
else return debit.
if the average is round to cent, this code will miss the two student spent 0.05.