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