On submitting the following code all the test cases are not getting passed for Winning CB scholarship question.
The code is attached below:
#include
using namespace std;
bool ispossible(int n,int m,int x, int y,int mid)
{
if(mid*x<=m+(n-mid)*y)
{
return true;
}
return false;
}
int main()
{
int n,m,x,y;
cin>>n>>m>>x>>y;
int s=0;
int e=n;
int ans=0;
while(s<=e)
{
int mid=(s+e)/2;
int total=m+(n-mid)*y;
bool x=ispossible(n,m,x,y,mid);
if(x)
{
ans=mid;
s=mid+1;
}
else
{
e=mid-1;
}
}
cout<<ans<<"\n";
}