How to solve REPROAD - SPOJ ?

Please provide detailed explanation to solve [Repair Road - SPOJ][1] this queation. I am trying to solve this using sliding window approach but unable to frame the solution perfectly. @admin @vijju
[1]: https://www.spoj.com/problems/REPROAD/

//