#include <bits/stdc++.h>
bool debug = false;
using namespace std;
clock_t t = clock();
void check_time() {
  t = clock() - t;
  cout << "Time taken " << ((double)t) / CLOCKS_PER_SEC << "s" << endl;
}
void print_pair(const pair<int, int> &par) {
  if (!debug) return;
  cout << "(" << par.first << " " << par.second << ")"
       << " ";
}
template <typename C>
void print_array(const C &data, int n) {
  if (!debug) return;
  cout << "[DEBUG] " << endl;
  for (int i = 0; i < n; ++i) {
    cout << data[i] << " ";
  }
  cout << endl;
}
template <typename C>
void print_container(const C &data) {
  if (!debug) return;
  cout << "[DEBUG] " << endl;
  for (const auto &v : data) {
    cout << v << " ";
  }
  cout << endl;
}
template <typename C>
void print_pairs(const C &data) {
  if (!debug) return;
  cout << "[DEBUG] " << endl;
  for (const auto &v : data) {
    print_pair(v);
  }
  cout << endl;
}
template <typename C>
void print_matrix(const C &data) {
  if (!debug) return;
  cout << "[DEBUG] " << endl;
  for (const auto &row : data) {
    for (const auto &v : row) {
      cout << v << " ";
    }
    cout << endl;
  }
  cout << endl;
}
int cmpS(pair<int, pair<int, int>> k1, pair<int, pair<int, int>> k2) {
  return k1.second < k2.second;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<pair<int, pair<int, int>>> info = vector<pair<int, pair<int, int>>>(n);
  set<pair<int, int>> coins;
  set<pair<int, long long>> resp;
  for (int i = 0; i < n; ++i) {
    info[i].first = i;
    cin >> info[i].second.first;
  }
  for (int i = 0; i < n; ++i) {
    cin >> info[i].second.second;
  }
  sort(info.begin(), info.end(), cmpS);
  for (int i = 0; i < n; ++i) {
    long long res = info[i].second.second;
    int contador = 0;
    for (auto it = coins.begin(); it != coins.end() && contador < k; ++it) {
      if (info[i].second.first > it->second) {
        res += -it->first;
        contador++;
      }
    }
    coins.emplace(make_pair(-info[i].second.second, info[i].second.first));
    resp.emplace(make_pair(info[i].first, res));
  }
  for (auto par : resp) {
    cout << par.second << " ";
  }
  cout << endl;
}
