#include<bits/stdc++.h>
using namespace std;
const int N = 210;
const int K = 2e4+10;
int n,k,b[N],c[N],dp[K],q[K],p[K],pre[N][K],num[K],fact[K];
int main(){
cin>>n;
for(int i=1;i<=n;i++) cin>>b[i];
for(int i=1;i<=n;i++) cin>>c[i];
cin>>k;
memset(dp,0x3f,sizeof(dp));
dp[0]=0;
for(int i=1;i<=n;++i){
int s=min(k/b[i],c[i]);
for(int d=0;d<b[i];++d){
int hh=0,tt=-1;
for(int j=0;j<=(k-d)/b[i];++j){
while(hh<=tt&&dp[d+j*b[i]]-j<=q[tt]) --tt;
q[++tt]=dp[d+j*b[i]]-j;
p[tt]=j;
fact[tt]=d+j*b[i];
if(hh<=tt&&p[hh]<j-s) ++hh;
if(q[hh]+j<dp[d+j*b[i]]){
dp[d+j*b[i]]=q[hh]+j;
pre[i][d+j*b[i]]=fact[hh];
}
}
}
}
cout<<dp[k]<<endl;
int x=n,y=k;
while(x!=0){
num[x]=(y-pre[x][y])/b[x];
y=pre[x][y];
x--;
}
for(int i=1;i<=n;i++) cout<<num[i]<<" ";
return 0;
}
单调队列写的,不知道哪里有问题,请求大佬帮助