Transporting Bananas

Source

I got this problem from Rustan Leino, who was told it by Rupak Majumdar. I modified it slightly.

I solved it and wrote up my solution.

Problem    

You have 900 bananas that you want to transport a distance of 300 km. The transport will be done by a monkey. The monkey can carry as many as 300 bananas at any one time. With each kilometer traveled (forward or backward), the monkey consumes one banana. How many bananas can you get across to the other side?

Solution     Reveal