#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef struct node
{
int love;
int bb;
}Node;
Node a[1005];
int dp[1005][1005];
bool cmp(Node a,Node b)
{
return a.bb > b.bb;
}
int getMax(int a,int b)
{
if(a > b)
return a;
else
return b;
}
int main()
{
int n,k;
while(scanf("%d%d",&n,&k) != EOF)
{
int i,j;
for(i = 1; i <= n;i++)
scanf("%d",&a[i].love);
for(i = 1;i <= n;i++)
scanf("%d",&a[i].bb);
sort(a+1,a+n+1,cmp);
int maxs = 0;
for(i = 1;i <= n;i++)
{
if(maxs < a[i].love)
maxs = a[i].love;
dp[i][1] = maxs;
}
for(i = 1;i <= n;i++)
for(j = 2;j <= i && j <= k; j++)
{
dp[i][j] = getMax(dp[i-1][j],dp[i-1][j-1] + a[i].love - (j-1)*a[i].bb);
}
printf("%d\n",dp[n][k]);
}
return 0;
}