CHANDF ! Can somebody Help me that what's wrong with my code(till SUBTASK 2)

My answer: https://www.codechef.com/viewsolution/32900220

Can somebody tell me why my code failed for subtask 2? What wrong with the approach. I tried with many test cases, but it worked …so what’s wrong?