Minimize rounded sum


  • 0
    C

    Given an array of numbers A = [x1, x2, ..., xn] and T = Round(x1+x2+... +xn).
    We want to find a way to round each element in A such that after rounding we get a new array B = [y1, y2, ...., yn] such that y1+y2+...+yn = T where yi = Floor(xi) or Ceil(xi), ceiling or floor of xi.
    We also want to minimize sum |x_i-y_i|


  • 0
    This post is deleted!

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.