Error on 4th Test case

I’ve written the code for ‘Blocked Billboard ii’ but i’ve been stuck on the fourth test case failure for a long while. I know it’s a simple problem but somehow, the other test cases work and I’m not able to wrap my head around it.

Here’s the link to the problem:
http://www.usaco.org/index.php?page=viewproblem2&cpid=783
Here’s my code:
https://ide.usaco.guide/N-m3mJJae7cALXSXsi5
Here’s the link to the test cases along with the usaco solution:

Thanks!

Have you tried downloading the test data?