armansuleimenov wrote:I don't think I completely understand what I am asked in this problem. Could someone explain me?
Think of the input in terms of nxm matrix. (0 based indexed)
Row i, column j means the studying ith course for j+1 hours can get you a score of L[j]
We want to find an solution vector x[] such that L[x]>=5 and sum(x+1,i=0..n-1)<=m and sum(L[x],i=0..n-1) is maximal.
Thanks for the suggestion above to add 1e-9 to my answer before rounding to two decimal places. With that one change, I got AC instead of the many WA's I was getting. Why do we need to add 1e-9 and how did you figure that out?
jaywinyeah wrote:Thanks for the suggestion above to add 1e-9 to my answer before rounding to two decimal places. With that one change, I got AC instead of the many WA's I was getting. Why do we need to add 1e-9 and how did you figure that out?
Because you may have the result 6.125 or something similar. The computer represents this number as: 6.12499999999, that is why the result may be rounded to 6.12, instead of 6.13.
I tried to solve the problem using DP but, even I'm almost sure that my solution is right, I'm still getting WA. Could someone post some test cases for me to try to find the error?