#include <bits/stdc++.h>
using namespace std;
long long n, k, ans[100005];
vector<pair<int, pair<int, int> > > kings;
vector<int> coins, getcoin;
priority_queue<pair<int, int> > topcoin;
bool cmp(pair<int, pair<int, int> > i, pair<int, pair<int, int> > j) {
  return i.first < j.first;
}
int main() {
  while (cin >> n >> k) {
    vector<pair<int, int> > tmp;
    kings.clear();
    getcoin.clear();
    while (!topcoin.empty()) topcoin.pop();
    for (int i = 0; i < n; i++) {
      pair<int, int> tmp1;
      cin >> tmp1.first;
      tmp.push_back(tmp1);
    }
    for (int i = 0; i < n; i++) {
      int tmp1;
      cin >> tmp1;
      tmp[i].second = tmp1;
      kings.push_back(make_pair(tmp[i].first, make_pair(tmp[i].second, i)));
    }
    sort(kings.begin(), kings.end(), cmp);
    for (int i = 0; i < n; i++) {
      long long nowcoin, score;
      nowcoin = score = kings[i].second.first;
      for (int j = 0; j < min(k, (long long)getcoin.size()); j++) {
        score += getcoin[j];
      }
      ans[kings[i].second.second] = score;
      if (getcoin.size() == 0)
        getcoin.push_back(nowcoin);
      else {
        if (nowcoin > getcoin[getcoin.size() - 1] || getcoin.size() < k) {
          int flag = 0;
          for (int j = 0; j < getcoin.size(); j++) {
            int tmp1, tmp2;
            if (nowcoin > getcoin[j]) {
              tmp1 = getcoin[j];
              getcoin[j] = nowcoin;
              for (int l = j + 1; l < getcoin.size(); l++) {
                tmp2 = getcoin[l];
                getcoin[l] = tmp1;
                tmp1 = tmp2;
              }
              if (getcoin.size() < k) {
                flag = 1;
                getcoin.push_back(tmp1);
              }
              break;
            }
          }
          if (getcoin.size() < k && !flag) {
            getcoin.push_back(nowcoin);
          }
        }
      }
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
