Here is the homework problem: http://www.usaco.org/index.php?page=viewproblem2&cpid=892. It's a nice problem that requires some algorithmic thinking in order to solve it, in contrast to the lots of brute force problems that we've seen recently.