#include <bits/stdc++.h>
#include <cstdint>
#include <iomanip>
#define PowerUp ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define BattleMode ll t;cin>>t;while(t--)
#define Thor solve();
#define Thunder if(t>0){cout<<line;}
#define ll long long
#define line "\n"
#define line3 cout<<line;
#define stop int abnmj; cin>>abnmj;
#define tap "\t"
#define loop(end,char) for(ll char=0;char<end;char++)
#define loopr(end,char) for(int char=end-1;char>=0;char--)
#define arrin(name) loop(name.size(),p){cin>>name[p];}
#define print(name) for(auto ik:name){cout<<ik<<" ";}
#define print2(name) for(auto ik:name){cout<<ik.first<<" "<<ik.second<<line;}
#define temple template<typename t,typename v>
#define all(x) x.begin(),x.end()
using namespace std;
const double pi = acos(-1);
const ll MOD = 1e9 + 7;
ll magic_powder;
ll cookies_poweder(ll number,vector<ll> &have,vector<ll> &recipe)
{
ll sz = have.size();
ll total_powder=0;
for (int i = 0; i < sz; i++)
{
ll powder_nedded=recipe[i]*number-have[i];
powder_nedded=((powder_nedded<0) ? (ll)0 : powder_nedded);
total_powder+=powder_nedded;
if (total_powder > magic_powder)
return true;
}
return false;
}
void solve()
{
ll ingredient;
cin>>ingredient>>magic_powder;
vector<ll> recipe(ingredient);
vector<ll> have (ingredient);
arrin(recipe)
arrin(have)
ll left=0,mid, right=3*1e9;
while (left < right)
{
mid = (right - left) / 2 + left;
if (cookies_poweder(mid,have,recipe))
right = mid;
else
left = mid+1;
}
if (cookies_poweder(right,have,recipe) )
right--;
cout<<right;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
PowerUp
Thor
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxjc3RkaW50PgojaW5jbHVkZSA8aW9tYW5pcD4KI2RlZmluZSBQb3dlclVwIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpO2Npbi50aWUoTlVMTCk7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