http://www.usaco.org/index.php?page=viewproblem2&cpid=896
usaco 2019 january silver contest problem- Mountain View.
This problem has weak test cases.
I submitted a solution with complexity of O(n^2) and it worked. I don’t think it should be that way.
The official solution has a complexity of O(nlogn) and it’s very elegant.
It should be fixed for future users.