What is wrong in my Naive approach?

This coding question was a part of my college competition and i am happy that i was able to solve 4 out of 5 questions. This discuss belongs to the 5th question “The Mountaineer”.

Link: https://www.hackerrank.com/contests/sastraweeklycontest1/challenges/the-mountaineer-

Any one can signup as the competition was already over and i am enthusiastic about this question.
Please mention the tips to solve this question.

My Naive approach is wrong.