#include<bits/stdc++.h>
using namespace std;
const int maxn=1005;
struct G
{
int m;
int p;
}P[maxn];
int n,k;
bool cmp(G a,G b)
{
return a.p>b.p;
}
int f[maxn][maxn];
int main()
{
freopen("pig.in","r",stdin);
freopen("pig.out","w",stdout);
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
scanf("%d",&P[i].m);
for(int i=1;i<=n;i++)
scanf("%d",&P[i].p);
sort(P+1,P+n+1,cmp);
for(int i=1;i<=n;i++)
for(int j=1;j<=k;j++)
f[i][j]=max(f[i-1][j],max(f[i][j-1],f[i-1][j-1]+max(P[i].m-(j-1)*P[i].p,0)));
printf("%d\n",f[n][k]);
return 0;
}