#include <bits/stdc++.h>
using namespace std;
struct Knight {
  int idx;
  long long power, coins, ans;
  vector<long long> valores;
} knights[100010];
int n, k;
long long respostas[100010], aux;
bool compare(Knight first, Knight second) { return first.power < second.power; }
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &knights[i].power);
    knights[i].idx = i;
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &knights[i].coins);
    knights[i].ans = 0;
  }
  sort(knights, knights + n, compare);
  respostas[knights[0].idx] = knights[0].coins;
  for (int i = 1; i < n; i++) {
    respostas[knights[i].idx] = knights[i].coins;
    if (k == 0) continue;
    int qtdPegoPeloAnterior = ((int)knights[i - 1].valores.size());
    for (int j = 0; j < ((int)knights[i - 1].valores.size()); j++) {
      knights[i].valores.push_back(knights[i - 1].valores[j]);
    }
    knights[i].valores.push_back(knights[i - 1].coins);
    if (qtdPegoPeloAnterior < k)
      knights[i].ans += knights[i - 1].ans;
    else {
      knights[i].ans += knights[i - 1].ans;
      sort(knights[i].valores.rbegin(), knights[i].valores.rend());
      aux = knights[i].valores[((int)knights[i].valores.size()) - 1];
      knights[i].valores.pop_back();
      knights[i].ans -= aux;
    }
    aux = 0;
    for (int j = 0; j < ((int)knights[i].valores.size()); j++)
      aux += knights[i].valores[j];
    respostas[knights[i].idx] += aux;
  }
  for (int i = 0; i < n; i++) {
    if (i != 0) printf(" ");
    printf("%lld", respostas[i]);
  }
  printf("\n");
  return 0;
}
