You have been given the task of transporting 3,000 apples 1,000 miles from Appleland to Bananaville. Your truck can carry 1,000 apples at a time. Every time you travel a mile towards Bananaville you must pay a tax of 1 apple but you pay nothing when going in the other direction (towards Appleland).
What is highest number of apples you can get to Bananaville?
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.
Note: This is not a perfect solution yet. Just some thoughts.
I assume that we can't divide the apples, so that you must always travel an integral number of miles.
Suppose we traverse the n -th mile for a n times (in the forward direction). Then we lose ∑ i = 1 1 0 0 0 a i apples just because we made all those trips, or in other words, we can get 3 0 0 0 − ∑ i = 1 1 0 0 0 a i apples through... can we? There's another restriction, the "1000 apples at a time" limit.
If we traverse the n -th mile for a n times, then we can only get at most 1 0 0 0 a n apples past the n -th mile (and a n of them are gone for the cost of the n -th mile). In other words, the number of apples we can get through is at most 1 0 0 0 a n − ∑ i = n 1 0 0 0 a i apples.
I think these are all the restrictions. The number of apples we can get through is bounded above by the minimum of all of these; that is, min { 3 0 0 0 − ∑ i = 1 1 0 0 0 a i } ∪ { 1 0 0 0 a n − ∑ i = n 1 0 0 0 a i ∣ 1 ≤ n ≤ 1 0 0 0 } . For the sake of brevity, let s 0 = 3 0 0 0 − ∑ i = 1 1 0 0 0 a i , s n = 1 0 0 0 a n − ∑ i = n 1 0 0 0 a i , so the answer is bounded by min { s i } . But there are 1000 variables to take care of; can we simplify it?
Of course we can. Clearly we need to have all a i 's to be at least 1. It also seems that no a i needs to be more than 3. And finally, it's pretty clear that the sequence of a i 's is non-increasing; if we traverse the n -th mile for a n times, we don't need to traverse the n + 1 -th mile for more than a n times, since all the load that's present can be carried in just a n trips past the n + 1 -th mile. Thus, we can actually simplify the expression to just two variables. Let p , q be integers satisfying 1 ≤ p ≤ q ≤ 1 0 0 0 such that a 1 = a 2 = … = a p = 3 , a p + 1 = a p + 2 = … = a q = 2 , and a q + 1 = a q + 2 = … = a 1 0 0 0 = 1 . Now most of the s i 's are redundant (if a n = a n + 1 , then s n ≤ s n + 1 ), so s n + 1 doesn't matter. The only important terms are s 1 , s p + 1 , s q + 1 .
Thus we're looking for p , q to maximize the value of min { 2 0 0 0 − p − q , 1 0 0 0 + 2 p − q , q } .
This is pretty much an integer programming problem. Had it been a normal real optimization problem, finding the best p , q would be as easy as equating the three expressions together (there are two variables and there will be two equations, so there should be a unique solution--and indeed there is, p = 3 1 0 0 0 , q = 3 2 5 0 0 , with the value of the expression being 3 2 5 0 0 ). But integer programming cannot be solved that way... can it?
As it turns out, this particular case can be solved approximately that way. We did get the solution p = 3 1 0 0 0 , q = 3 2 5 0 0 , so we try the points around it, p = 3 3 3 or 3 3 4 and q = 8 3 3 or 8 3 4 . We find that q = 8 3 3 (and either choice of p ) gives the value of the expression being 833, and since we know the real optimization problem has value 3 2 5 0 0 < 8 3 4 , we know for sure that our 833 is optimal for our integer programming case.
So we know that the number of apples that we can get through is at most 833. Can we achieve this? As it turns out, yes, we can:
This corresponds precisely with p = 3 3 3 , q = 8 3 3 . Thus the answer should be 833 . Note that this is "should be" because I'm still not very certain about the italicized parts above.