Book Exercise WA

I am WA
question link:-
my solution:-
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 store the wors and the other store min upto top.

but i am getting wrong ans.plzz correct me