Please help why wrong answer on this algortihm

question link : Contest Page | CodeChef
solution : Error Page | CodeChef