#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, MOD = 10139, MAXN = 1e12 + 10, LG = 20, M = 1e7, P = 727,
          Sq = 100;
const long long inf = 2e18 + 10;
long long ans[N], ps[N], c[N], pw[N];
vector<pair<long long, int> > v;
vector<long long> ret;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> pw[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  v.push_back(make_pair(-MOD, -1));
  for (int i = 1; i <= n; i++) {
    v.push_back(make_pair(pw[i], i));
  }
  sort(v.begin(), v.end());
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    ans[v[i].second] = cnt + c[v[i].second];
    ret.push_back(-c[v[i].second]);
    sort(ret.begin(), ret.end());
    while ((int)ret.size() > k) ret.pop_back();
    cnt = 0;
    for (int j = 0; j < (int)ret.size(); j++) cnt += (-ret[j]);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
