#include <bits/stdc++.h>
using namespace std;
struct night {
  long long p, c;
  int num;
} q[100005];
bool cmp(night a, night b) { return a.p < b.p; }
long long a[15];
long long ans[100005];
int main() {
  int n, k, pos;
  long long sum = 0, rem;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &q[i].p);
    q[i].num = i;
  }
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &q[i].c);
  }
  sort(q, q + n, cmp);
  for (int i = 0; i < k; i++) {
    a[i] = q[i].c;
    sum += q[i].c;
    ans[q[i].num] = sum;
  }
  for (int i = k; i < n; i++) {
    ans[q[i].num] = sum + q[i].c;
    pos = -1;
    rem = q[i].c;
    for (int j = 0; j < k; j++) {
      if (a[j] < rem) {
        pos = j;
        rem = a[j];
      }
    }
    if (pos > -1) {
      a[pos] = q[i].c;
      sum = sum + a[pos] - rem;
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%I64d ", ans[i]);
  }
  cout << endl;
  return 0;
}
