Getting wrong ans in some test cases

#include
using namespace std;

bool poss(int n,int dhas,int r,int g,int p){
if((p*r)<=dhas+((n-p)*g)){
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;
if(poss(n,m,x,y,mid)){
ans=mid;
s=mid+1;
}
else{
e=mid-1;
}
}
cout<<ans<<endl;

return 0;

}

hello @mansi25

use long long .

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.