WA in Online Shopping pls help....

here is my solution which clears subtask 2 but gives wa in subtask 1.
The logic seems correct. (I saw the editorial and some solutions) but I cant seem to figure out why it gives wa in subtask 1 ans 3 pls help…

Question link : http://www.codechef.com/problems/COUPON

Solution link : http://www.codechef.com/viewsolution/7022521

Thanks.

//