#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int n, k;
struct node {
  int i;
  long long p, c;
} a[MAXN];
bool cmp1(node a, node b) { return a.p < b.p; }
bool cmp2(node a, node b) { return a.i < b.i; }
priority_queue<int, vector<int>, greater<int> > que;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) a[i].i = i;
  for (int i = 1; i <= n; i++) cin >> a[i].p;
  for (int i = 1; i <= n; i++) cin >> a[i].c;
  sort(a + 1, a + 1 + n, cmp1);
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += a[i - 1].c;
    que.push(a[i - 1].c);
    if (que.size() > k) {
      sum -= que.top();
      que.pop();
    }
    a[i].p = a[i].c + sum;
  }
  sort(a + 1, a + 1 + n, cmp2);
  for (int i = 1; i <= n; i++) cout << a[i].p << " ";
  return 0;
}
