#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, pair<long long, long long> > > myvect;
vector<long long> current;
long long sum = 0;
vector<long long> sums;
vector<long long> extra;
map<int, long long> mymap;
int main() {
  int i, j, k, n, m;
  long long a, b, c, d;
  vector<long long>::iterator result;
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%lld", &a);
    extra.push_back(a);
  }
  for (i = 0; i < n; i++) {
    scanf("%lld", &b);
    myvect.push_back(make_pair(extra[i], make_pair(b, i)));
  }
  sort(myvect.begin(), myvect.end());
  for (i = 0; i <= k; i++) {
    current.push_back(myvect[i].second.first);
    sum += myvect[i].second.first;
    mymap[myvect[i].second.second] = sum;
  }
  for (; i < n; i++) {
    result = min_element(current.begin(), current.end());
    sum = sum - (*result);
    sum = sum + myvect[i].second.first;
    current.erase(result);
    current.push_back(myvect[i].second.first);
    mymap[myvect[i].second.second] = sum;
  }
  for (i = 0; i < n; i++) {
    printf("%lld ", mymap[i]);
  }
  return 0;
}
