Unable to figure out the fault in code.

My answer to the problem code LCH15JGH url http://www.codechef.com/problems/LCH15JGH is giving correct output specified in the problem. I also tried at least 10 other random test cases in which the code gives appropriate output. Still I am getting wrong answer. I can’t figure out the test case where my code gives wrong output. Can you please figure out the fault in my code and also specify the test case where the code isn’t working? My solution is: http://www.codechef.com/viewsolution/6020008 . I know the code uses simple array arithmetics while the tester’s and editor’s solutions are using advance data structures, but still I want to know where is the fault in my code… Can you please help me out with this?