#include <bits/stdc++.h>
using namespace std;
int main() {
  int TESTS = 1;
  while (TESTS--) {
    long long int n, k;
    cin >> n >> k;
    long long int p[n], c[n];
    map<long long int, long long int> ma;
    for (long long int i = 0; i < n; i++) {
      cin >> p[i];
      ma[p[i]] = i;
    }
    for (long long int i = 0; i < n; i++) {
      cin >> c[i];
    }
    vector<pair<long long int, long long int> > v(n);
    for (long long int i = 0; i < n; i++) {
      v[i] = make_pair(p[i], c[i]);
    }
    sort((v).begin(), (v).end());
    vector<long long int> ans(n);
    map<long long int, long long int> bkj;
    for (long long int i = 0; i < n; i++) {
      if (i == 0) {
        ans[ma[v[0].first]] = v[0].second;
        bkj[v[i].second]++;
        continue;
      }
      map<long long int, long long int>::iterator it = bkj.end();
      it--;
      long long int e = 0;
      long long int sm = v[i].second;
      for (it = it; e <= k; it--) {
        sm += it->first * min(it->second, k - e);
        e += it->second;
        if (it == bkj.begin()) {
          break;
        }
      }
      bkj[v[i].second]++;
      ans[ma[v[i].first]] = sm;
    }
    for (long long int i = 0; i < n; i++) {
      cout << ans[i] << " ";
    }
  }
  return 0;
}
