#include <bits/stdc++.h>
using namespace std;
struct Cavaler {
  int p;
  int c;
  int ind;
  long long sol;
};
int n, k;
Cavaler v[100001];
multiset<int> s;
bool comp1(Cavaler a, Cavaler b) { return a.p < b.p; }
bool comp2(Cavaler a, Cavaler b) { return a.ind < b.ind; }
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> v[i].p;
  for (int i = 1; i <= n; i++) cin >> v[i].c;
  for (int i = 1; i <= n; i++) v[i].ind = i;
  sort(v + 1, v + n + 1, comp1);
  for (int i = 1; i <= k; i++) {
    v[i].sol = v[i - 1].sol + v[i].c;
    s.insert(v[i].c);
  }
  for (int i = k + 1; i <= n; i++) {
    v[i].sol = v[i].c;
    for (auto it : s) v[i].sol += it;
    s.insert(v[i].c);
    s.erase(s.begin());
  }
  sort(v + 1, v + n + 1, comp2);
  for (int i = 1; i <= n; i++) cout << v[i].sol << " ";
  return 0;
}
