Hello I need help with the following problem:
we have m
balloons and unlimited amount of candy.
Some kid wants us give him ni
balloons in every i
day (array n
).
He also has a tax array b
- which is tax bi
on day i
.
If we give the kid ni
balloons on day i
he is happy. If we give k
balloons k < ni
on day i
, we have to give the kid (ni - k)*bi
candy.
We have to give the balloons in such way as to minimize the maximum amount of candy we give ON A GIVEN day.
Example:
we have 6
balloons (m = 6)
n = 1, 3, 3, 3, 2
b = 4, 1, 5, 3, 7
we give balloons in following way
g = 0, 0, 2, 2, 2
In this way we have to give a maximum of (3 -2) * 5 = 5
on day 3 (indexing start from 1).
Please help me find an efficient solution to this problem. My current solution is greedy by removing one balloon at a time but is way too slow, because m < 10^18
. ai < 10^9 bi < 10^9 n < 10^5