Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<unordered_set>
- using namespace std;
- #define fio ios_base::sync_with_stdio(false)
- #define ll long long int
- #define s3(x,y,z) s(x)+s(y)+s(z)
- #define s(x) scanf("%lld",&x)
- #define p(x) printf("%lld\n",x)
- ll n,m,x,y;
- bool solve(ll z){
- return (z*x<=m+(n-z)*y);
- }
- int main()
- {
- ll t=1;
- // s(t);
- while(t--){
- s3(n,m,x);
- s(y);
- ll lo=0;
- ll hi=n;
- ll ans=0;
- while(lo<=hi){
- ll mid=lo+hi;
- mid>>=1;
- if(solve(mid))
- {
- lo=mid+1; ans=mid;
- }
- else hi=mid-1;
- }
- p(ans);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment