#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
long long int ans[MAX];
pair<long long int, pair<long long int, long long int> > p[MAX];
int main() {
  long long int n, k, i, j, sum = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first;
  }
  for (int i = 0; i < n; i++) {
    cin >> p[i].second.first;
    p[i].second.second = i;
  }
  sort(p, p + n);
  multiset<long long int> q;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      ans[p[i].second.second] = p[i].second.first;
    } else {
      ans[p[i].second.second] = p[i].second.first;
      long long int sz = q.size();
      sz = min(sz, k);
      multiset<long long int>::iterator it = q.begin();
      while (sz--) {
        ans[p[i].second.second] += (0 - *it);
        it++;
      }
    }
    q.insert(-p[i].second.first);
  }
  for (int i = 0; i < n; i++) {
    printf("%lld ", ans[i]);
  }
  return 0;
}
