#include <bits/stdc++.h>
using namespace std;
struct Knight {
  int pos;
  int power;
  long long coin;
  long long score;
  bool operator<(const Knight &a) const { return this->coin < a.coin; }
};
int n, k;
Knight knights[100010];
bool compare(const Knight &a, const Knight &b) { return a.power > b.power; }
bool comparePos(const Knight &a, const Knight &b) { return a.pos < b.pos; }
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &(knights[i].power));
    knights[i].pos = i;
  }
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &(knights[i].coin));
    knights[i].score = knights[i].coin;
  }
  sort(knights, knights + n, compare);
  priority_queue<Knight> q;
  for (int i = 0; i < n; i++) {
    q.push(knights[i]);
  }
  vector<Knight> tempV;
  int count;
  Knight curKnight;
  for (int i = 0; i < n; i++) {
    tempV.clear();
    count = 0;
    while ((q.empty() == false) && (count < k)) {
      curKnight = q.top();
      q.pop();
      if (knights[i].power > curKnight.power) {
        tempV.push_back(curKnight);
        knights[i].score = knights[i].score + curKnight.coin;
        count++;
      }
    }
    for (int i = 0; i < tempV.size(); i++) q.push(tempV[i]);
  }
  sort(knights, knights + n, comparePos);
  printf("%I64d", knights[0].score);
  for (int i = 1; i < n; i++) {
    printf(" %I64d", knights[i].score);
  }
  printf("\n");
  return 0;
}
