NZEC error

Plz anybody help (One can tell me why am i getting nzec error)

I have devoted my whole day in solving this but getting NZEC error .i checked for so many testcases Plz check it at below link

Mysolution :- http://ideone.com/kfeqgc http://www.codechef.com/viewsolution/4120282

Problem link:-http://www.codechef.com/problems/D1

I just implemented the editorial of this question.

//