template <classT> inlinevoidread(T &x){ x = 0;T w = 1; char c = 0; while(c<'0' || c>'9'){ if(c=='-') w = -1; c = getchar(); } while(c>='0' && c<='9'){ x = ((x<<3)+(x<<1))+c-'0'; c = getchar(); } x = x*w; } int n; ll q[15],a[15],b[15]; ll ans = 0;
voidsolve(){ read(n); for(int i=1;i<=n;i++) read(q[i]); for(int i=1;i<=n;i++) read(a[i]); for(int i=1;i<=n;i++) read(b[i]); for(int y=0;y<=1e6;y++){ bool flag = 0; for(int i=1;i<=n;i++){ if(y*b[i]>q[i]){ //检查当前y是否合法,不合法直接退出 flag = 1; break; } } if(flag) break; ll x = INF; for(int i=1;i<=n;i++){ if(a[i]>0) x = fmin(x,floor(q[i]-b[i]*y)*1.0/a[i]); //求出最大的且满足要求的x } if(x>=0) ans = fmax(ans,x+y); //更新答案 } cout<<ans; }
intmain(){ int t = 1; // read(t); for(int tt=1;tt<=t;tt++){ solve(); } }