Solution to a bonus problem found at: 
https://liu.kattis.scrool.se/problems/ferryloading4