fork download
  1. /*
  2. #################################################################################
  3. # #
  4. # ####### # # ###### # # # ##### ####### #
  5. # # # # # # # # ## # # # # # #
  6. # # ####### ###### # # # # # # # # #
  7. # # # # # # ####### # # # # # # #
  8. # # # # # # # # # # # # # # #
  9. # ####### # # # # # # # ## ##### # #
  10. # #
  11. # -- met7nke4 by => zhran07 -- #
  12. #################################################################################
  13.  */
  14. #include <bits/stdc++.h>
  15. #define Mbappe ios::sync_with_stdio(false); cin.tie(nullptr);
  16. #define ll long long
  17. #define int ll
  18. #define ld long double
  19. #define all(v) v.begin(),v.end()
  20. #define rall(v) v.rbegin(),v.rend()
  21. const double PI = acos(-1.0);
  22. using namespace std;
  23.  
  24. template<class T>
  25. istream &operator>>(istream &in, vector<T> &v) {
  26. for (auto &i: v)in >> i;
  27. return in;
  28. }
  29.  
  30. template<class T>
  31. ostream &operator<<(ostream &out, vector<T> &v) {
  32. for (auto &i: v)out << i << ' ';
  33. return out;
  34. }
  35.  
  36. void run() {
  37. #ifndef ONLINE_JUDGE
  38. freopen("input.txt", "r", stdin);
  39. freopen("output.txt", "w", stdout);
  40. #endif
  41. }
  42. int n,k;
  43. bool can(int mid,vector<int>&a,vector<int>&b) {
  44. int sum=0;
  45. for (int i=0;i<n;i++) {
  46. if (mid*a[i]>b[i])
  47. sum+=(mid*a[i])-b[i];
  48. }
  49. if (sum<=k)return true;
  50. return false;
  51. }
  52. void Vamoooos__ACCPTED() {
  53. cin >> n >> k;
  54. vector<int> a(n),b(n);
  55. cin>>a>>b;
  56. int l=0,r=2e9,ans=0;
  57. while (l<=r) {
  58. int mid=l+(r-l)/2;
  59. if (can(mid,a,b)) {
  60. ans=mid;
  61. l=mid+1;
  62. }
  63. else r=mid-1;
  64. }
  65. cout << ans << endl;
  66. }
  67. int32_t main() {
  68. run();
  69. Mbappe;
  70. // int t;cin >> t;while (t--)
  71. Vamoooos__ACCPTED();
  72. }
  73.  
  74.  
  75. ////============================ متنستاش تصلي علي النبي =======
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
2000000000