#include <bits/stdc++.h>
using namespace std;
int n, k;
long long kq[1000000];
priority_queue<int> q;
pair<int, pair<int, int> > a[1000000];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].first;
    a[i].second.second = i;
  }
  for (int i = 1; i <= n; ++i) cin >> a[i].second.first;
  sort(a + 1, a + n + 1);
  long long s = 0;
  for (int i = 1; i <= n; ++i) {
    while (q.size() > k) {
      s += q.top();
      q.pop();
    }
    kq[a[i].second.second] = s + a[i].second.first;
    q.push(-a[i].second.first);
    s += a[i].second.first;
  }
  for (int i = 1; i <= n; ++i) cout << kq[i] << " ";
  return 0;
}
