#include <bits/stdc++.h>
using namespace std;
bool sortd(const pair<long long int, long long int>& a,
           const pair<long long int, long long int>& b) {
  return a.second < b.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int a[n], b[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) cin >> b[i];
  if (k == 0) {
    for (long long int i = 0; i < n; i++) cout << b[i] << " ";
    exit(0);
  }
  vector<pair<long long int, long long int>> v;
  map<long long int, long long int> m;
  for (long long int i = 0; i < n; i++) {
    v.push_back({a[i], b[i]});
  }
  sort(v.begin(), v.end());
  vector<long long int> s;
  m[v[0].first] = v[0].second;
  for (long long int i = 1; i <= k; i++) {
    long long int sum = v[i].second;
    s.push_back(v[i - 1].second);
    long long int j = i - 1;
    sort(v.begin(), v.begin() + i, sortd);
    while (j >= 0) {
      sum += v[j].second;
      j--;
    }
    m[v[i].first] = sum;
  }
  vector<long long int> sum;
  for (long long int i = k + 1; i < n; i++) {
    long long int suml = v[i].second;
    long long int m = min_element(s.begin(), s.end()) - s.begin();
    if (s[m] < v[i - 1].second) {
      s.erase(s.begin() + m);
      s.emplace_back(v[i - 1].second);
    }
    for (auto i : s) suml += i;
    sum.push_back(suml);
  }
  for (long long int i = k + 1; i < n; i++) {
    m[v[i].first] = sum[i - k - 1];
  }
  for (long long int i = 0; i < n; i++) {
    cout << m[a[i]] << " ";
  }
}
