#include <bits/stdc++.h>
using namespace std;
long long n, k;
vector<pair<long long, long long> > power;
vector<pair<long long, long long> > org;
vector<pair<long long, long long> > val;
long long cnt[100005];
long long ans[100005];
int main() {
  scanf("%lld %lld", &n, &k);
  for (long long i = 0; i < n; i++) {
    long long a;
    scanf("%lld", &a);
    power.push_back(make_pair(a, i));
    org.push_back(make_pair(a, i));
  }
  for (long long i = 0; i < n; i++) {
    long long a;
    scanf("%lld", &a);
    val.push_back(make_pair(a, i));
    ans[i] += a;
  }
  long long lim = 0;
  sort(power.begin(), power.end());
  reverse(power.begin(), power.end());
  sort(val.begin(), val.end());
  reverse(val.begin(), val.end());
  if (k) {
    for (long long i = 0; i < n; i++) {
      long long key = val[i].first;
      long long own = org[val[i].second].first;
      for (long long j = lim;; j++) {
        if (power[j].first > own) {
          long long idx = power[j].second;
          cnt[j]++;
          ans[idx] += key;
          if (cnt[j] == k) {
            lim = max(lim, j + 1);
          }
        } else
          break;
      }
    }
  }
  for (long long i = 0; i < n; i++) printf("%lld ", ans[i]);
  return 0;
}
