#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  long long c[100000], tc[11], m;
  pair<int, long long> p[100000];
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> m;
    p[i] = {m, i};
  }
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  sort(p, p + n);
  p[0] = {p[0].second, c[p[0].second]};
  for (int i = 1; i < n; ++i) {
    tc[0] = c[p[i - 1].first];
    sort(tc, tc + 11);
    m = c[p[i].second];
    for (int i = 10; i >= 11 - k; --i) {
      m += tc[i];
    }
    p[i] = {p[i].second, m};
  }
  sort(p, p + n);
  for (int i = 0; i < n; ++i) cout << p[i].second << ' ';
  return 0;
}
