#include <bits/stdc++.h>
using namespace std;
long long int n, val[100002], ans[100002], vis[100002], pw[100002];
vector<pair<long long int, int> > p;
priority_queue<pair<long long int, int> > pq;
int k;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    p.push_back({x, i});
    pw[i] = x;
  }
  for (int i = 0; i < n; i++) {
    cin >> val[i];
  }
  sort((p).begin(), (p).end());
  for (int i = n - 1; i >= 0; i--) {
    pq.push({val[p[i].second], p[i].second});
  }
  long long int prev = 0;
  int cnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    int flg = 0;
    long long int x = 0;
    if (i == n - 1) {
      cnt = k;
    } else {
      if (vis[p[i].second] == 1) {
        cnt++;
      }
    }
    cnt = min(k, cnt);
    while (!pq.empty()) {
      if (cnt == 0) {
        break;
      }
      if (pw[pq.top().second] > pw[p[i].second]) {
        pq.pop();
        continue;
      }
      vis[pq.top().second] = 1;
      cnt--;
      x += pq.top().first;
      if (pq.top().second == p[i].second) {
        cnt++;
      }
      pq.pop();
    }
    if (!vis[p[i].second]) {
      x += val[p[i].second];
    }
    cnt = 0;
    ans[p[i].second] = prev + x;
    prev = ans[p[i].second] - val[p[i].second];
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
}
