#include <bits/stdc++.h>
using namespace std;
long long n, k;
vector<long long> c;
vector<long long> p;
vector<long long> srt;
bool cmp(long long a, long long b) { return p[a] < p[b]; }
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  p.resize(n);
  c.resize(n);
  for (auto &t : p) cin >> t;
  for (auto &l : c) cin >> l;
  for (long long i = 0; i < n; i++) srt.push_back(i);
  sort(srt.begin(), srt.end(), cmp);
  priority_queue<long long> cur;
  vector<long long> ans(n);
  for (auto t : srt) {
    ans[t] = c[t];
    long long cnt = 0;
    long long oo = 0;
    vector<long long> pops;
    while (!cur.empty() && cnt < k) {
      pops.push_back(cur.top());
      oo += cur.top();
      cur.pop();
      cnt++;
    }
    for (auto t : pops) cur.push(t);
    ans[t] += oo;
    cur.push(c[t]);
  }
  for (auto t : ans) {
    cout << t << " ";
  }
  cout << endl;
}
