#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, p[100005], c[100005], ans[100005];
  map<long long, long long> m;
  multiset<long long> s;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> p[i], m[p[i]] = i;
  for (int j = 0; j < n; ++j) cin >> c[j];
  sort(p, p + n);
  for (int i = 0; i < n; ++i) {
    long long pos = m[p[i]];
    ans[pos] = 0;
    ans[pos] += c[pos];
    long long tmp = 0, j = k;
    for (multiset<long long>::iterator it = s.begin(); j and it != s.end();
         ++it, --j) {
      tmp -= *it;
    }
    ans[pos] += tmp;
    s.insert(-c[pos]);
  }
  for (long long i = 0; i < n; ++i) cout << ans[i] << " ";
}
