Alice has 100 dollars in her bank account, and she wants to withdraw at least 10 dollars in the course of 7 days. However, the bank has a weird policy. On the day, she will be paid dollar if she doesn't withdraw any money. If she wants to withdraw, she can only withdraw exactly dollars.
The table below describes and on the day:
i | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
p | 5 | 4 | 8 | 4 | 9 | 6 | 3 |
q | 4 | 9 | 5 | 2 | 5 | 2 | 6 |
Assume that Alice cannot deposit any money, what is the maximum amount of money can Alice has in her bank account after 7 days?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Let Bal be the balance in case of no withdrawal, Bal = 1 0 0 + ∑ i = 1 7 p i = 139
Next, get all possible combinations of q i where sum is ≥ 1 0 . Of course, we want to have the minimum number of q i s.
(Without writing the algorithm used) the combination are as follows: + the loss for withdrawing
q 1 + q 7 ⇒ (4+6) + (5+3) = 18 ⇐ Min
q 2 + q 3 ⇒ (9+5) + (4+8) = 26
q 2 + q 7 ⇒ (9+3) + (4+6) = 22
q 3 + q 5 ⇒ (5+5) + (8+9) = 27
q 3 + q 7 ⇒ (5+6) + (8+3) =22
q 4 + q 6 + q 7 ⇒ (2+2+6) + (4+6+3) = 23
Note: There might be some other combinations but are not written because they are redundant. For example, a 1 + a 2 + a 3 ≥ 1 0 and a 1 + a 3 ≥ 1 0 . The extra addend on the first expression is unnecessary because we are looking the minimum loss.
Now, B a l − M i n ⟹ 1 3 9 − 1 8 = 1 2 1