
这道题很容易想到是二分 但是因为可能会爆LL 所以要加一波特判
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const LL M=1e6+,mx=1e18;
LL read(){
LL ans=,c=getchar();
while(c<''||c>'') c=getchar();
while(c>=''&&c<=''){ans=ans*+(c-''); c=getchar();}
return ans;
}
LL n,S,mn;
LL h[M],w[M],yy[M];
bool check(LL k){
LL sum=S;
for(int i=;i<=n;i++)if(k>=yy[i]){
if(mx/w[i]<=k) return ;
if(sum>h[i]+w[i]*k) sum-=h[i]+w[i]*k;
else return ;
}
return sum<=;
}
int main()
{
freopen("tree.in","r",stdin);
freopen("tree.out","w",stdout);
n=read(); S=read(); mn=read();
for(int i=;i<=n;i++) h[i]=read();
for(int i=;i<=n;i++) w[i]=read();
for(int i=;i<=n;i++){
LL now=mn-h[i];
if(now%w[i]==) yy[i]=now/w[i];
else yy[i]=now/w[i]+;
}
LL l=,r=mx;
while(l<=r){
LL mid=(l+r)>>;
if(check(mid)) r=mid-;
else l=mid+;
}
printf("%lld\n",l);
return ;
}