#include<iostream>
#include<algorithm>
using namespace std;
typedef struct node
{
int value;
int bb;
}Node;
Node a[1001];
int dp[1001][1001];
int lvs[1001][1001];
bool cmp(Node a,Node b)
{
if(a.bb != b.bb)
return a.bb > b.bb;
else
return a.value > b.value;
}
int getMax(int a,int b)
{
if(a > b)
return a;
else
return b;
}
int main()
{
int n,k;
while(cin>>n>>k)
{
int i,j;
for(i = 1;i <= n;i++)
{
scanf("%d",&a[i].value);
}
for(i = 1; i <= n;i++)
{
scanf("%d",&a[i].bb);
}
sort(a+1,a+n+1,cmp);
for(i = 1;i <= n;i++)
for(j = 1;j <= k;j++)
lvs[i][j] = a[i].value - (j-1)*a[i].bb;//经过j天之后的数值
int maxs = 0;
for(i = 1; i <= n;i++)
{
if(a[i].value > maxs)
maxs = a[i].value;
dp[i][1] = maxs;//第一个初始化为数值最大的那个数
}
for(i = 2;i <= n;i++)
{
for(j = 2; j <= k && j <= i;j++)
{
if(i-1 >= j)
dp[i][j] = getMax(dp[i-1][j],dp[i-1][j-1] + lvs[i][j]);dp[i][j] = MAX(dp[i-1][j] , dp[i-1][j-1] + X)//dp[i][j] 表示前i个人中选j个的最优值
else
dp[i][j] = dp[i-1][j-1]+lvs[i][j];
}
}
cout<<dp[n][k]<<endl;
}
return 0;
}