#include <bits/stdc++.h>
using namespace std;
struct bitch {
  long long idx, pts, cns;
  bitch() {}
  bitch(long long a, long long b, long long c) {
    pts = a;
    cns = b;
    idx = c;
  }
};
bool comp(bitch a, bitch b) { return a.pts < b.pts; }
long long n, k;
bitch a[100001];
vector<long long> ans[100001];
vector<long long> v;
void fix(long long x) {
  v.push_back(x);
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  if ((int)v.size() > k) v.pop_back();
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    a[i].idx = i;
    cin >> a[i].pts;
  }
  for (int i = 1; i <= n; i++) cin >> a[i].cns;
  sort(a + 1, a + n + 1, comp);
  for (int i = 1; i <= n; i++) {
    long long idx = a[i].idx;
    long long coin = a[i].cns;
    ans[idx] = v;
    ans[idx].push_back(a[i].cns);
    fix(coin);
  }
  for (int i = 1; i <= n; i++) {
    long long res = 0;
    for (auto nx : ans[i]) res += nx;
    cout << res << " ";
  }
}
