#include <bits/stdc++.h>
using namespace std;
long long dp[1005][1005] = {0};
int cc(long long i) {
  int ans = 0;
  while (i) {
    if (i % 2) ans++;
    i /= 2;
  }
  return ans;
}
int main() {
  int n, k;
  cin >> n >> k;
  int a;
  int coin[n];
  vector<pair<int, int>> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> a;
    arr[i] = make_pair(a, i);
  }
  for (int j = 0; j < n; j++) {
    cin >> coin[j];
  }
  sort(arr.begin(), arr.end());
  vector<long long> anss(n);
  vector<long long> att;
  long long temp = 0;
  long long ans = 0;
  if (k == 0) {
    for (int i = 0; i < n; i++) cout << coin[i] << " ";
    return 0;
  }
  for (int i = 0; i <= k; i++) {
    ans = coin[arr[i].second];
    for (int j = i - 1; j >= 0; j--) {
      ans += coin[arr[j].second];
      if (i == k) att.push_back(coin[arr[j].second]);
    }
    anss[arr[i].second] = ans;
    if (i == k) temp = ans - coin[arr[i].second];
  }
  sort(att.begin(), att.end());
  for (int i = k + 1; i < n; i++) {
    ans = temp;
    if (coin[arr[i - 1].second] > att[0]) {
      ans += coin[arr[i - 1].second] - att[0];
      att[0] = coin[arr[i - 1].second];
    }
    sort(att.begin(), att.end());
    anss[arr[i].second] = ans + coin[arr[i].second];
    temp = ans;
  }
  for (int i = 0; i < n; i++) cout << anss[i] << " ";
}
