I don’t understand the solution of this problem given on USACO. Please help me understand what the problem actually wants, and what should be our approach in order to solve this problem, explaining every step.
This same problem is explained thoroughly in the CPH Book, Section 2.4(Page No. 21)
Actually this book is a good companion, if you are planning to solve the CSES Problem Set. Goes well with it.