What is wrong in this code?

#include
using namespace std;
int main() {
int n,m,x,y;
cin >> n>> m>> x>> y;
int p = m / x;
if( p >= n){
cout << n;
}
else{
int l = n - p;
if( l > 1){
int z = m % x;
int k = (z + y) / x;
if( k < l){
cout << p + k;
}
else{
cout << p + k - 1;
}
}
else{
cout << n - 1;

	}
}
return 0;

}

this is not correct way to solve this question
your logic will not be applicable to all cases

join this meet i will explain

now i left the meet
if you join drop a msg here

please accept the request

are you available now?
before joining meet let me know

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.