Help with my code

I am doing a binary search with the search space of the number of students (0 to n) but I am getting half of the test cases wrong. I can’t figure out what’s going wrong.
include
using namespace std ;
define ll long long

bool isPossible(int curr_max,int n, int m, int x , int y){
ll needed = curr_max*x ;
ll available = (m + (n-curr_max)*y) ;
return needed <= available ;
}

int MaxStudents(int n,int m, int x ,int y){
int s = 0 ;
int e = n ;
int ans = 0 ;

while(s <= e){
	int mid = (s+e)/2 ;

	if(isPossible(mid,n,m,x,y)){
		ans = mid ;
		s = mid + 1;
	}
	else {
		e = mid - 1 ;
	}
}

return ans  ;

}

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

use long long int instead of int
Corrected code