selling tickets:GETTING WA

I am getting wrong answer for http://www.codechef.com/problems/TICKETS
my solution http://www.codechef.com/viewsolution/4164945 is satisfying the given test cases and I checked with many test cases.
Please help…

//