#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, k;
int p[maxn];
int c[maxn];
int idx[maxn];
long long ans[maxn];
bool comp(int a, int b) { return p[a] < p[b]; }
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", p + i);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", c + i);
    idx[i] = i;
  }
  sort(idx + 1, idx + n + 1, comp);
  priority_queue<int> pq;
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    int index = idx[i];
    while (pq.size() > k) {
      sum += pq.top();
      pq.pop();
    }
    ans[index] = sum;
    sum += c[index];
    pq.push(-c[index]);
  }
  for (int i = 1; i <= n; ++i) {
    printf("%I64d ", ans[i] + c[i]);
  }
  return 0;
}
