When he has more than 2000 bananas, it costs him 5 bananas / mile to
transport them, since he makes 3 trips forward and 2 trips back.
When he has more than 1000 bananas, it costs him 3 bananas / mile, for 2
trips forward and 1 trip back.
And when he has 1000 or fewer, it's 1 banana / mile.
I think the way to do it is: see how far he can get 2000 bananas, then 1000
bananas, and then make one final trip.
200 miles at the rate of 5 bananas / mile = 1000 bananas cost.
So if the first stopping point is at 200 miles,
he would carry 1000, eat 200, drop 600, and eat 200.
Then he would do that again.
On the third trip, he doesn't eat the second 200, so at the 200 mile
marker he has 600 + 600 + 800 = 2000 bananas.
If the second leg is 333 miles, it works out as:
carry 1000, eat 333, drop 334, eat 333.
carry 1000, eat 333, drop 667.
Now he has 1001 bananas, and it's just as well to throw one away. To
make it come out exact, we'd need to use fractional miles and fractional
bananas.
Now we have 1000 bananas at the 533 mile marker.
For the last leg, he just carries the last 1000 bananas,
eating 467 along the way, and arriving with 533 bananas.
If the initial legs are shorter, it works out the same.
If the initial legs are longer, he does more miles at higher banana /
mile rates, ending up with fewer bananas.....
old one...but good one....