I am getting wrong answer for test-case 1,2,5 would you please tell me what's wrong in my code

#include
using namespace std;
// n no of student appear in exam
// m no of coupons bhaiya has
// x minimum coupons rquired to get 100 schlorship
// y coupons paid by the students who failed in exam
// nget students who didn’t get scholarship
int Scholarship(int n,int m,int x,int y){
int s=0,e=n;
int final_ans=0;

while(s<=e){
    int mid=(s+e)/2;
    int nget=n-mid;
    int total_Coupons=m+nget*y;
    int total_schol_req=mid*x;
    if(total_schol_req<=total_Coupons){
        final_ans=mid;
        s=mid+1;
    }
    else{
        e=mid-1;
    }
}
return final_ans;

}
int main(){
int n,m,x,y;
cin>>n>>m>>x>>y;
cout<<Scholarship(n,m,x,y);
return 0;
}

@Himanshu0123 using of long long int will work if you will still get wrong ans on submission do tag

1 Like