Guest User

Untitled

a guest
May 24th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<unordered_set>
  3. using namespace std;
  4. #define fio ios_base::sync_with_stdio(false)
  5.  
  6. #define ll long long int
  7. #define s3(x,y,z) s(x)+s(y)+s(z)
  8. #define s(x) scanf("%lld",&x)
  9. #define p(x) printf("%lld\n",x)
  10. ll n,m,x,y;
  11.  
  12. bool solve(ll z){
  13. return (z*x<=m+(n-z)*y);
  14. }
  15.  
  16. int main()
  17. {
  18.  
  19. ll t=1;
  20. // s(t);
  21. while(t--){
  22. s3(n,m,x);
  23. s(y);
  24. ll lo=0;
  25. ll hi=n;
  26. ll ans=0;
  27. while(lo<=hi){
  28. ll mid=lo+hi;
  29. mid>>=1;
  30. if(solve(mid))
  31. {
  32. lo=mid+1; ans=mid;
  33. }
  34. else hi=mid-1;
  35. }
  36. p(ans);
  37. }
  38. return 0;
  39. }
Add Comment
Please, Sign In to add comment