#include <bits/stdc++.h>
using namespace std;
const long long inff = 0x3f3f3f3f3f3f3f3f;
long long n, k, s[100008];
struct as {
  long long x, y, z;
} a[100008];
bool cmp(as a, as b) { return a.x < b.x; }
multiset<long long, greater<long long>> se;
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i(1); i <= (n); ++i) scanf("%I64d", &a[i].x);
  for (int i(1); i <= (n); ++i) scanf("%I64d", &a[i].y), a[i].z = i;
  sort(a + 1, a + n + 1, cmp);
  int qw = 0, j;
  for (int i(1); i <= (n); ++i) {
    if ((i - 1) <= k)
      qw = i - 1;
    else
      qw = k;
    j = 0;
    s[a[i].z] += a[i].y;
    for (auto it = se.begin(); it != se.end(); it++) {
      if (qw == 0) break;
      s[a[i].z] += *it;
      if (j + 1 == qw) break;
      j++;
    }
    se.insert(a[i].y);
  }
  for (int i(1); i <= (n); ++i) {
    cout << s[i] << " ";
  }
  puts("");
  return 0;
}
