#include <bits/stdc++.h>
using namespace std;
int main() {
  priority_queue<long long int> pq;
  long long int n, k;
  cin >> n >> k;
  pair<pair<long long int, long long int>, long long int> p;
  vector<pair<pair<long long int, long long int>, long long int> > a;
  long long int po[n];
  long long int c[n];
  long long int i = 0;
  while (i < n) {
    cin >> po[i];
    i++;
  }
  i = 0;
  while (i < n) {
    cin >> c[i];
    i++;
  }
  i = 0;
  while (i < n) {
    p.first.first = po[i];
    p.first.second = c[i];
    p.second = i;
    a.push_back(p);
    i++;
  }
  sort(a.begin(), a.end());
  long long int ans[n];
  i = 0;
  long long int count, sum, index, element;
  while (i < n) {
    element = a[i].first.second;
    if (i == 0) {
      ans[a[i].second] = element;
    } else {
      vector<long long int> answer;
      count = k;
      sum = 0;
      while (count > 0 && !pq.empty()) {
        sum += pq.top();
        answer.push_back(pq.top());
        pq.pop();
        count--;
      }
      int help = 0;
      while (help < answer.size()) {
        pq.push(answer[help]);
        help++;
      }
      ans[a[i].second] = sum + element;
    }
    pq.push(element);
    i++;
  }
  i = 0;
  while (i < n) {
    cout << ans[i] << " ";
    i++;
  }
}
