#include <bits/stdc++.h>
using namespace std;
long long a[200005], b[200005], sorted[200005];
pair<long long, long long> pii[200005], pp[200005];
int main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sorted[i] = a[i];
    pp[i] = make_pair(a[i], i);
  }
  sort(sorted, sorted + n);
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    pii[i] = make_pair(a[i], b[i]);
  }
  sort(pp, pp + n);
  sort(pii, pii + n);
  multiset<long long> st;
  long long id = 0;
  for (long long i = 0; i < n; i++) {
    long long p = lower_bound(sorted, sorted + n, pp[i].first) - sorted;
    p--;
    if (p == -1) continue;
    for (long long j = id; j <= p; j++) {
      st.insert(pii[j].second);
    }
    id = p + 1;
    long long x = k;
    auto it = st.end();
    it--;
    while (x) {
      b[pp[i].second] += *it;
      if (it == st.begin()) break;
      it--;
      x--;
    }
  }
  for (long long i = 0; i < n; i++) cout << b[i] << " ";
}
