Please explain how the logic in ispossible function here is computed and working?

Hello @hrishikeshjanjal,

In the binary search, ans represents the no. of students who can get 100% discount and our aim is to maximize it.

X: no. of coupons required by each student to get 100% discount.
So,
(ans*X): No. of coupons required by ‘ans’ no. of students to get 100% discount.

M: Coupons Available initially.
N: Total no. of students.
Y: no. of coupons paid by each badly performing student.
So,
(X-ans): No. of students who cannot get 100% discount.
(X-ans)*Y: Extra coupons that we can collect from weak students.
M+(X-ans)*Y: Total coupons we can collect or have if we plan to give discount coupons to ‘ans’ no. of students.

Hence, ans is a valid number of students if and only if,
(ans*X) <= M+(X-ans)*Y

Hope, this would help.
Give a like, if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.