#include <bits/stdc++.h>
using namespace std;
long long fill(
    priority_queue<long long, vector<long long>, greater<long long>> &pq) {
  priority_queue<long long, vector<long long>, greater<long long>> pq2 = pq;
  long long ans = 0;
  while (pq2.size()) {
    ans += pq2.top();
    pq2.pop();
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<pair<long long, pair<long long, int>>> kn(n);
  for (int i = 0; i < n; i++) {
    cin >> kn[i].first;
    kn[i].second.second = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> kn[i].second.first;
  }
  sort(kn.begin(), kn.end());
  vector<long long> ans(n, 0);
  priority_queue<long long, vector<long long>, greater<long long>> pq;
  for (int i = 0; i < n; i++) {
    int w = kn[i].second.second;
    ans[w] = kn[i].second.first;
    ans[w] += fill(pq);
    if (pq.size() == k && pq.size() > 0 && kn[i].second.first > pq.top()) {
      pq.pop();
      pq.push(kn[i].second.first);
    } else if (pq.size() < k) {
      pq.push(kn[i].second.first);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
