#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, k;
  cin >> n >> k;
  vector<pair<long long, pair<long long, long long>>> a;
  vector<long long> ans(n, 0);
  for (long long i = 0; i < n; i++) {
    long long q;
    cin >> q;
    a.push_back({q, {0, i}});
  }
  for (long long i = 0; i < n; i++) {
    long long q;
    cin >> q;
    a[i].second.first = q;
  }
  if (k == 0) {
    for (long long i = 0; i < n; i++) {
      cout << a[i].second.first << " ";
    }
    cout << "\n";
    return 0;
  }
  sort(a.begin(), a.end());
  long long temp_ans = 0;
  vector<long long> g1;
  for (long long i = 0; i < n; i++) {
    temp_ans = 0;
    if (i == 0) {
      ans[a[i].second.second] = a[i].second.first;
      g1.push_back(a[i].second.first);
      continue;
    }
    if (g1.size() < k) {
      g1.push_back(a[i].second.first);
      for (auto m : g1) {
        temp_ans += m;
      }
      ans[a[i].second.second] = temp_ans;
    } else {
      sort(g1.begin(), g1.end());
      temp_ans += a[i].second.first;
      for (auto m : g1) {
        temp_ans += m;
      }
      ans[a[i].second.second] = temp_ans;
      if (a[i].second.first > g1[0]) {
        g1[0] = a[i].second.first;
      }
    }
  }
  for (auto m : ans) {
    cout << m << " ";
  }
  cout << "\n";
  return 0;
}
