#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class T>
inline void arin(T* st, T* nd) {
  while (st < nd) cin >> *st++;
}
const int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
bool cmd(pair<long long, long long> inp, pair<long long, long long> b) {
  if (inp.first < b.first) return true;
  return false;
}
int main() {
  int n, k, a, b;
  cin >> n >> k;
  multiset<long long> x;
  vector<pair<long long, long long> > inp(n);
  map<long long, int> ans;
  long long q[n];
  for (int i = 0; i < (int)(n); i++) {
    cin >> a;
    q[i] = a;
    ans[a] = i;
  }
  for (int i = 0; i < (int)(n); i++) {
    cin >> a;
    inp[i] = (make_pair(q[i], a));
  }
  vector<pair<long long, long long> > cop = inp;
  sort(inp.begin(), inp.end(), cmd);
  vector<long long> so;
  long long sum = 0;
  x.insert(0);
  for (int i = 0; i < n; i++) {
    sum = inp[i].second;
    multiset<long long>::iterator it = x.end();
    it--;
    for (int j = 1; j <= k; j++) {
      if (i - j >= 0) sum += *(it);
      it--;
    }
    q[ans[inp[i].first]] = sum;
    x.insert(inp[i].second);
  }
  for (int i = 0; i < (int)(n); i++) cout << q[i] << " ";
}
