#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e5 + 20;
long long mark[20];
int main() {
  long long i, j, n, m, k;
  cin >> n >> k;
  long long p[n], c[n];
  for (i = 0; i < n; ++i) cin >> p[i];
  for (i = 0; i < n; ++i) cin >> c[i];
  pair<long long, long long> p1[n], p2[n];
  for (i = 0; i < n; ++i)
    p1[i] = make_pair(p[i], c[i]), p2[i] = make_pair(c[i], p[i]);
  sort(p1, p1 + n);
  sort(p2, p2 + n);
  map<long long, long long> mp;
  long long sw = 1;
  for (i = n - 1; i >= 0; --i) {
    j = n - sw;
    if (p2[j].second == p1[i].first) {
      while (1) {
        sw++;
        if (n - sw < 0) {
          j = 0;
          break;
        }
        if (p2[n - sw].second < p1[i].first) break;
      }
    }
    long long cu = 0;
    long long ans = p1[i].second;
    while (1) {
      if (j < 0) break;
      if (cu == k) break;
      if (p2[j].second < p1[i].first) {
        ans += p2[j].first;
        cu++;
      }
      j--;
    }
    mp[p1[i].first] = ans;
  }
  for (i = 0; i < n; ++i) {
    cout << mp[p[i]] << ' ';
  }
  return 0;
}
