Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
If we have integer values in the array then we just need to subtract the target those integer values, so we reduced the problem.
Similarly if we have non integer values we have two options to put them flor(value) or ceil(value) = floor(value) + 1, so the idea is to just subtract floor(value).
Now the problem is different for each position we can sum just add 0 or 1 in order to sum the target, minimizing the deltas. This can be solved with DP.