#include <bits/stdc++.h>
using namespace std;
template <typename tp>
tp read() {
  char c = getchar();
  tp x = 0;
  bool sgn = 0;
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') sgn = 1, c = getchar();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return sgn ? -x : x;
}
template <typename tp>
void write(tp x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x >= 10) write(x / 10);
    putchar(x % 10 + '0');
  }
}
struct T {
  long long num, p, c;
  bool operator<(const T& x) const { return c < x.c; }
} a[100005], t[100005];
long long n, m, ans[100005], cntt;
bool cmp(const T& x, const T& y) { return x.p < y.p; }
signed main() {
  n = read<long long>(), m = read<long long>();
  for (long long i = 1; i <= n; i++) a[i].p = read<long long>(), a[i].num = i;
  for (long long i = 1; i <= n; i++) a[i].c = read<long long>();
  sort(a + 1, a + n + 1, cmp);
  long long j = 1;
  for (long long i = 1; i <= n; i++) {
    while (a[j].p < a[i].p) t[++cntt] = a[j], j++;
    sort(t + 1, t + cntt + 1);
    if (cntt > m) {
      for (long long p = 1, q = cntt - m + 1; p <= m; p++, q++) t[p] = t[q];
      cntt = m;
    }
    for (long long p = 1; p <= cntt; p++) ans[a[i].num] += t[p].c;
    ans[a[i].num] += a[i].c;
  }
  for (long long i = 1; i <= n; i++) write(ans[i]), putchar(' ');
  return 0;
}
