Help on "The Lazy Cow"

http://www.usaco.org/index.php?page=viewproblem2&cpid=416

I’m confused on the solution to “The Lazy Cow”.
Specifically, after we “rotate” the graph by 45 deg, what exactly do we add? And can someone please explain why the solution works?

Thanks!