why WA in digjump

why my code is giving WA in digjump
here is my code http://www.ideone.com/rcZw8e
plz help i need to know the fault
i ve tried the test cases which were randomly generated and all others given in the editorial even my algo sort of matches the algo in editorial