Book Exercise WA

I am WA
question link:-BEX Problem - CodeChef
my solution:-CodeChef: Practical coding for everyone
My solution is differnt from the editorial and in the editorial they have used a good method of not adding books having greatyer reamaining exercises.
Howerver I have used 2 stacks.one store the wors and the other store min upto top.

but i am getting wrong ans.plzz correct me