#include <bits/stdc++.h>
using namespace std;
const int N = 2205;
void upd(pair<long long, int> &a, pair<long long, int> b) {
  if (a.first > b.first || (a.first == b.first && a.second < b.second)) a = b;
}
int n, k;
long long a[N], b[N];
pair<long long, int> dp[N][N];
const pair<long long, int> neutr = {(long long)2e18 + 7, 0};
pair<long long, int> get(long long lambda) {
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) dp[i][j] = neutr;
  }
  dp[0][0] = {0, 0};
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (dp[i][j] != neutr) {
        if (j < n)
          upd(dp[i + 1][j + 1], {dp[i][j].first + a[i], dp[i][j].second});
        if (j > 0)
          upd(dp[i + 1][j - 1],
              {dp[i][j].first + b[i] + lambda, dp[i][j].second + 1});
        upd(dp[i + 1][j],
            {dp[i][j].first + a[i] + b[i] + lambda, dp[i][j].second + 1});
        upd(dp[i + 1][j], dp[i][j]);
      }
    }
  }
  auto ans = neutr;
  for (int i = 0; i <= n; ++i) upd(ans, dp[n][i]);
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  long long l = -1e13, r = 1e13;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    auto have = get(mid);
    if (have.second >= k)
      l = mid;
    else
      r = mid;
  }
  auto ans = get(l);
  cout << ans.first - l * ans.second;
  return 0;
}
