Failing at a testcase

i think my appoach to the problem is right but i am not able to pass testcase10 .don’t know where the problem is
it will be nice if you can help with the mistake in my code.
i have commented the code ,so that its easy for you to understand my approach.
any help is appriciated

QUESTION:
http://codeforces.com/problemset/problem/186/A
ANSWER:

can someone help me out with this

Hi @kirtidabas5

Please ask your doubts from the doubt support section in your course.