#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, indx;
  long long k, x;
  scanf("%d%lld", &n, &k);
  long long ar[n + 2];
  for (int i = 0; i < n; i++) scanf("%lld", &ar[i]);
  map<long long, pair<long long, int> > mp;
  vector<long long> ans(n + 2);
  multiset<long long, greater<long long> > coin;
  multiset<long long, greater<long long> >::iterator it;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &x);
    mp.insert(make_pair(ar[i], make_pair(x, i)));
  }
  for (auto hehe : mp) {
    indx = hehe.second.second;
    ans[indx] = hehe.second.first;
    it = coin.begin();
    for (int i = 0; i < k; i++) {
      if (coin.empty())
        break;
      else if (it == coin.end())
        break;
      else {
        ans[indx] += *it;
        it++;
      }
    }
    coin.insert(hehe.second.first);
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) printf(" ");
    printf("%lld", ans[i]);
  }
  printf("\n");
  return 0;
}
