Winning CB Scholarship

The logic I thought is that we need to increase the number of students recieving scholarship should be max.

So let’s say that max is some value z which lies between 0 and n (this value cannot be greater than number of students obviously).

So total coupons is z * x ------- 1

where x is the coupon required for getting scholarship.

This value will be less than or equal to m + (n - z) * y -----2

Where m is the coupon already given and y is the penality of students who have performed bad. I came up with eq 2 as we are already getting m coupons and the remaining students may or may not performing badly ie may not pay the penality.

But I’m failing some test cases . Please help me with that.

hey @aroraswati859 you logic looks quite good to me but since constraints are very large(1 ≤ N,M,X,Y ≤ 10^9 ​) that means N,M,X,Y cannot be stored in int. So change all the datatypes from ‘int’ to ‘long’ and your testcases will pass.

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.