Whats the error in this implementation?
line 7 should be
if(ans>=n){
Hi, I am really sorry for my blunder, I misunderstood your code. Actually the code was correct.
But, the question is a bit vague and it looks like it means that every child who does not get the scholarship, needs to pay ‘y’ coupons each.
The output for
10 3 1 1
according to the question, should be 6.
4 children pay 1 extra (so now in total 3 + 4 = 7 coupons) and the rest 6 will get scholarship.
So is my code correct…if yes then why tc are failed?
No, please see the above case and you will get what actually the question means.
For the above tc-3 students will get scholarship and one will give his point so one morestudent will get scholarship…so total is 4 only…how the answer is 7?
The answer is not 7, it is 6.
6 students get the scholarship, rest 4 pay extra coupons.
how it should be 6 according to me its coming as 4,ie,one student pay his coupon and 3 student will get scholarship from total coupons,so total is 3+1=4
Why only 1??
All the remaining students have to pay m coupons each.
how the answer is 7 please explain?
Bhaii, 7 nhi hai 6 hai answer.
6 students get the scholarship (require 6 * 1 = 6 coupons), rest 4 pay extra coupons (pay 4 * 1 = 4 coupons).
4 coupons are paid and 3 were already there, so now total = 7, this is enough to sponsor the 6 students.