Where I got wrong in this problem? (FASTROAD)

Problem: https://www.codechef.com/ALPAST01/problems/FASTROAD
Solution: https://www.codechef.com/viewsolution/27912818