No testcase passed

#include<bits/stdc++.h>
using namespace std;

bool check(int n,int m,int x,int y,int mid){
int val1 = mid*x;
int val2 = m + (n-mid)*y;
if(val1>=val2){
return true;
}
return false;

}

int ans(int n,int m,int x,int y){
int start = 0;
int end = n;
int ans = -1;
while(start<=end){
int mid = (start+end)/2;
bool check1 = check(n,m,x,y,mid);
if(check1==true){
ans = mid;
start = mid + 1;
}else{
end = mid - 1;
}
}

return ans;

}

int main() {
int n;
cin>>n;
int m;
cin>>m;
int x;
cin>>x;
int y;
cin>>y;
cout << ans(n,m,x,y) << endl;
}
what is wrong with code?

in the above if condition, the condition should be val2>=val1. since we need to make sure that available coupons(val2) must be greater than needed coupons.

thanks

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.