#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<pair<pair<int, int>, int>> c;
  for (int i = 0; i < n; i++) {
    c.push_back({{a[i], b[i]}, i});
  }
  sort(c.begin(), c.end());
  vector<long long> ans(n);
  multiset<long long, greater<long long>> x;
  for (int i = 0; i < n; i++) {
    long long sum = 0;
    if (i > k) {
      auto y = x.begin();
      int j = 0;
      while (j < k) {
        sum += *y;
        y++;
        j++;
      }
    } else {
      for (auto y = x.begin(); y != x.end(); y++) {
        sum += *y;
      }
    }
    x.insert(c[i].first.second);
    sum += c[i].first.second;
    ans[c[i].second] = sum;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
