#include <bits/stdc++.h>
using namespace std;
set<pair<long long, long long> > st;
map<long long, long long> tp;
long long ans[100013];
int main() {
  long long n, k;
  cin >> n >> k;
  vector<pair<long long, long long> > v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first;
    v[i].first = -v[i].first;
    tp[v[i].first] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> v[i].second;
    v[i].second = -v[i].second;
    st.insert({v[i].second, v[i].first});
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    long long an = -v[i].second, j = 0;
    for (auto it = st.begin(); it != st.end() && j < k; it++, j++) {
      if (it->second == v[i].first) {
        j--;
        continue;
      } else
        an += (-(it->first));
    }
    st.erase(st.find({v[i].second, v[i].first}));
    ans[tp[v[i].first]] = an;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << ' ';
  }
  return 0;
}
